Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-08-26
05:28 • Closed ticket [1267380fff]: UpdateStringOfList: overflow detection plus 6 ot... artifact: 50a3ffc439 user: dkf
04:56 • Ticket [1267380fff]: 4 changes artifact: 00cf56cdfc user: hobbs
04:49 • Pending ticket [1267380fff]. artifact: a69bc6f699 user: dkf
2005-08-23
19:17 • New ticket [1267380fff]. artifact: 56e9c0dfea user: dgp

UpdateStringOfList: overflow detection

Closed / Fixed1267380fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-08-23 19:17:24
% set x [string repeat a 65536]; concat
% set y [lrepeat 65536 $x]; concat
% string length $y
Segmentation fault

The string rep of $y would need
a buffer of 4295032831 bytes, but
that exceeds INT_MAX.

When the scanner (over-)estimates
the buffer size, it tries to count up
the need for 4295163905 bytes, but
the calculation overflows, wraps around
and it concludes the need for only
196609 bytes.  This gets allocated easily,
and we happily start writing to this
way too short buffer until we march off
into segfaulting .

Would be better for the scanner to
detect the overflow (any negative length
should be the indicator) and Tcl_Panic, 
I think.
dkfplain2005-08-26 04:49:45
Logged In: YES 
user_id=79902

Fixed in HEAD; does this need backporting?
hobbsplain2005-08-26 04:56:33
Logged In: YES 
user_id=72656

as a possible buffer overflow, yes please.
dkfplain2005-08-26 05:28:40
Logged In: YES 
user_id=79902

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