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.