Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-05
07:10 • Ticket [220996ffff] 'string index' doesn't do bounds checking st... artifact: c47451d3ff user: dgp
2000-11-02
04:40 • Ticket [220996ffff]: 5 changes artifact: b1b857a75e user: ericm
04:35 • Closed ticket [220996ffff]. artifact: 3afa815b15 user: ericm
03:50 • Ticket [220996ffff]: 4 changes artifact: 0430c138f3 user: ericm
2000-11-01
14:51 • New ticket [220996ffff]. artifact: b807bc6f0b user: nobody

'string index' doesn't do bounds checking

Closed / Fixed220996ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-11-01 14:51:16
'string index' has a bug.  If you give an index value that's larger than
the length of the string, or less than 0, it doesn't do bounds checking.

If you look around line 1210 of tclCmdMZ.c in tcl 8.3.2, you'll see a
reference to string[index] but there was no check to verify that 'index'
is within the string array bound. 

I suggest that this:
 Tcl_SetByteArrayObj(resultPtr,
                        (unsigned char *)(&string1[index]), 1)

be replaced with this:

 if ((index >= 0) && (index < length1)) {
                    Tcl_SetByteArrayObj(resultPtr,
                            (unsigned char *)(&string1[index]), 1);
                }
ericmplain2000-11-02 03:50:33
This bug has already been fixed for 8.4a2.

   Eric Melski                            The Other Tcl Guy
   ericm at ajubasolutions.com            Ajuba Solutions
ericm Closed ticket [220996ffff]. [History diff]2000-11-02 04:35:32
ericm Ticket [220996ffff]: 5 changes [History diff]2000-11-02 04:40:25
dgp Ticket [220996ffff]: 3 changes [History diff]2001-04-05 07:10:07
Log in (anonymous is fine) to add a comment.