INST_CONCAT1 no overflow protection
Closed / Fixed2669109fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2009-03-06 18:48:16
appends that overflow the max length of a string lead to corrupted nonsense.
ferrieuxplain2009-03-08 04:15:26
It appears there is code duplication between INST_CONCAT1 and Tcl_AppendObjToObj. Is there a good reason ? Refactoring would solve this issue.
dgpplain2009-03-20 01:28:10
Demo:
% set foo [string repeat a 8421505]; concat
% set cmd {set bar }
set bar
% append cmd [string repeat {$foo} 255]; concat
% eval $cmd; concat
% string length $bar
-2147483521
dgpplain2009-03-20 01:33:20
Demo that doesn't need a system capable of
big allocations:
% set foo [string repeat a 16843010]; concat
% set cmd {set bar }
set bar
% append cmd [string repeat {$foo} 255]; concat
% eval $cmd; concat
make: *** [shell] Segmentation fault
dgpplain2009-03-20 02:05:01
Was going to turn those into a test, but once the bug is fixed, the proper behavior will be to panic, which isn't test friendly.
dgpplain2009-03-20 02:58:09
File Added - 318622: 2669109.patch Here's a patch for the HEAD. File Added: 2669109.patch
dgpplain2009-03-20 20:41:29
More reliable demo:
proc demo foo "set bar [string repeat {$foo} 255]"
demo [string repeat a 16843010]; concat
dgpplain2009-03-20 21:36:28
allow_comments - 1 fixed on all branches
Log in (anonymous is fine) to add a comment.
Attachments:
- 2669109.patch [download] added by dgp on 2009-03-20 02:58:09. [details]