Overview
| Artifact ID: | 51961aa16e9dfe1729e4a5a91619cbe43f133e51 |
|---|---|
| Ticket: | 2107634fffffffffffffffffffffffffffffffff
extend maximum command length to maxint |
| User & Date: | dgp on 2009-10-20 04:46:56 |
Changes
- icomment:
The problem to avoid is when the "length" value passed to Tcl_(Attempt)SetObjLength no longer really represents what the caller desires because of integer overflow. The really trouble some case is when offset is already INT_MAX. Then the doubling rule led to an attempt to allocate a new string of length 2*offset + TCL_UTF_MAX + 1, which wraps around the unsigned integer range and allocates a string of length 2. Then later code tries to write long strings into a buffer of length 2 and segfaults. Shifting the location of the TCL_UTF_MAX offset in the calculation means that the calculation of length is limited to 2*offset, which can be no bigger that UINT_MAX -1, which when interpreted as a signed int is negative, and triggers the appropriate failure. The whole TCL_UTF_MAX shifting business is needed to satisfy the demands of the Tcl_ExternalToUtf() routine. The +1 that used to be there was apparently in place to make sure that space for a terminating NUL was allocated. Since the Tcl_*SetObjLength() routines already provide for this, it was removed.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"