|
2014-05-08
| ||
| 17:49 | • Closed ticket [272e866f1e]: Uncontrolled overflow in ReadBytes() plus 6 othe... artifact: ad5d81cdfe user: dgp | |
|
2014-04-10
| ||
| 14:35 | • Ticket [272e866f1e]: 3 changes artifact: b7005323d5 user: gustafn | |
|
2014-01-16
| ||
| 22:42 | • Ticket [272e866f1e]: 4 changes artifact: ed5fe63eb4 user: dkf | |
|
2014-01-15
| ||
| 20:22 | • Ticket [272e866f1e]: 3 changes artifact: 73f87bf9b6 user: dgp | |
| 20:21 | [272e866f1e][965a39e314] Revise ReadBytes so that it uses the bytearray growth algorithm already in ... check-in: 128d902c33 user: dgp tags: bug-272e866f1e | |
|
2013-12-09
| ||
| 15:28 | • Ticket [272e866f1e] Uncontrolled overflow in ReadBytes() status still Open w... artifact: a2f106f10b user: gustafn | |
| 15:27 | • Ticket [272e866f1e]: 3 changes artifact: e8b7ae7e2f user: gustafn | |
|
2013-12-03
| ||
| 15:44 | • Ticket [272e866f1e]: 3 changes artifact: 6cabaa4725 user: dgp | |
| 15:24 | • Ticket [272e866f1e]: 4 changes artifact: a2926849b1 user: dgp | |
|
2013-11-14
| ||
| 22:27 | • Ticket [272e866f1e]: 6 changes artifact: defac9d228 user: dkf | |
|
2013-11-12
| ||
| 19:07 | • Add attachment tclI-2GB.patch to ticket [272e866f1e] artifact: 5ad002f73f user: gustafn | |
| 19:05 | • New ticket [272e866f1e] Crash when reading a file of e.g 1.1 GB. artifact: 1bd98c743c user: gustafn | |
Uncontrolled overflow in ReadBytes()
Closed / Fixed272e866f1ec0af1927a7899a81b1c58395832096Created 13 years agoUpdated 13 years ago
Descriptionplain2013-11-12 19:05:42
When reading a file with e.g. 1.1 GB via set content [read $f] Tcl crashes due to the doubling policy of reallocs on machines where sizeof(int) == 32 (which is as well the case on 64 bit Linux). Due to doubling the length of the buffer, the length variable of type "int" becomes negative on values larger than 1GB. While one can discuss the usefulness of reading large files into memory, the situation can be improved quite easily by limiting the doubling policy to 2GB (actually INT_MAX). The problem happened in a Tcl-based zip-file generator, when the size of a single file is larger than 1.x GB. A sample patch is available (I assume i can attach the patch after writing the ticket). Most probably there are more places in Tcl, where a similar patch might be useful.
Referenced by1
128d902c33[272e866f1e][965a39e314] Revise ReadBytes so that it uses the bytearray growth algorithm already in TclAppendBytesToByteArray() rather than poorly making its own. check-in2014-01-15 20:21:07
dkfhtml2013-11-14 22:27:26
dgp has worked on limits…
dgpplain2013-12-03 15:24:52
We've tidied up many overflow scenarios but apparently not this one. Similar trouble may lurk in ReadChars()
dgpplain2013-12-03 15:44:26
The fix for the analogous problem in ReadChars() was made in checkin http://core.tcl.tk/tcl/info/cdf00220922c7d8d so it's been good since 8.5.8. The ticket covering the development of that change is http://core.tcl.tk/tcl/info/2107634 Looks like we just need the analogous fix put in place for binary channels.
gustafnplain2013-12-09 15:27:53
yep, using Tcl_AttemptSetObjLength() seems better, although the function is quite complex. i would prefer a function Tcl_GrowObjLength(... desired_length, required_min_length) to keep the changes mininmal and to encapsulate the growing behavior.
gustafnplain2013-12-09 15:28:16
yep, using Tcl_AttemptSetObjLength() seems better, although the function is quite complex. i would prefer a function Tcl_GrowObjLength(... desired_length, required_min_length) to keep the changes mininmal and to encapsulate the growing behavior.
dgpplain2014-01-15 20:22:13
See branch bug-272e866f1e for a possible fix.
dkfhtml2014-01-16 22:42:43
Patch seems reasonable, but removing the stuff currently elided with #if 0 is better practice. We have fossil to keep the history of bad ideas for us now!
gustafnplain2014-04-10 14:35:37
We tested the the patches on the mentioned branch in tcl8.5, and everything seems to work fine. We had to copy/paste manually some macro definitions on generic/tclInt.h and the function TclAppendBytesToByteArray which were introduced on tcl 8.6.
dgpplain2014-05-08 17:49:52
This is fixed on trunk and core-8-5-branch now.
Log in (anonymous is fine) to add a comment.