Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-04-08
09:17 • Closed ticket [05ff16e799]: signed integer overflow in ExtendStringRepWithUnicod... artifact: 0e8f283693 user: jan.nijtmans
09:10
Fix [05ff16e799]: signed integer overflow in ExtendStringRepWithUnicode() check-in: 4958391d5a user: jan.nijtmans tags: core-8-6-branch
2022-04-07
19:12 • Add attachment 05ff16e799.diff to ticket [05ff16e799] artifact: 489bd977ce user: chrstphrchvz
18:58 • New ticket [05ff16e799] signed integer overflow in ExtendStringRepWithUnicode()<... artifact: c22669188a user: chrstphrchvz

signed integer overflow in ExtendStringRepWithUnicode()

Closed / Fixed05ff16e799ef5d6d15ad1330425f243e5c49d13fCreated 5 years agoUpdated 5 years ago
Descriptionwiki2022-04-07 18:58:01
Example script (assumes your Tcl already has the fix for [0e8fd6c6d5]):
set z [string repeat "\u0000" 1073741820]
puts stderr [::tcl::unsupported::representation $z]
# create string obj with longest possible unicode rep and no string rep set zz [string replace $z 0 1 $z] puts stderr [::tcl::unsupported::representation $zz]
# force generating string rep (should abort due to exceeding max size for a Tcl value) set ZZ [string toupper $zz] puts stderr [::tcl::unsupported::representation $ZZ]

Output containing UBSan -fsanitize=signed-integer-overflow error (which the attached patch prevents):

value is a pure string with a refcount of 2, object pointer at 0x604000041490, string representation "..."
value is a string with a refcount of 2, object pointer at 0x604000041c10, internal representation 0x316793800:0xbebebebebebebebe, no string representation
tcl/generic/tclStringObj.c:3344:7: runtime error: signed integer overflow: 2147483646 + 2 cannot be represented in type 'int'
max size for a Tcl value (2147483647 bytes) exceeded
(tclsh aborted)
Referenced by1
  • 4958391d5aFix [05ff16e799]: signed integer overflow in ExtendStringRepWithUnicode() check-in2022-04-08 09:10:22
jan.nijtmanswiki2022-04-08 09:17:49

Merged to 8.6 and 8.7 (no problem on 9.0)

Thanks!

Log in (anonymous is fine) to add a comment.