Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2011-03-07
03:07 • Closed ticket [3192636fff]: TclFindElement permits buffer overrun plus 7 oth... artifact: 07c71a7834 user: dgp
02:53 • Open ticket [3192636fff]. artifact: 84b4e9ad10 user: dgp
00:53 • Pending ticket [3192636fff]. artifact: 8c03df5d7c user: dgp
2011-03-06
11:36 • Ticket [3192636fff]: 4 changes artifact: ea04d7cb88 user: dgp
2011-03-05
14:38 • Ticket [3192636fff]: 4 changes artifact: b0c6287867 user: dgp
2011-02-26
04:49 • Ticket [3192636fff]: 4 changes artifact: 7aaa5a072e user: dgp
2011-02-25
21:27 • New ticket [3192636fff]. artifact: 8daa4a5b8e user: dgp

TclFindElement permits buffer overrun

Closed / Fixed3192636fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2011-02-25 21:27:25
The TclFindElement() routine accepts a pair of
arguments (CONST char *list) and (int listLength)
which determine the string to be parsed. 

Examination of that string ought not continue beyond
the byte (list + listLength) but if that point happens
in the middle of a backslash escape sequence, nothing
is done to prevent it.

Looking for any ways to demo this via public access...
dgpplain2011-02-26 04:49:26
% testparser {{*}\u218} 8
- {{*}\u218} 1 expand {{*}\u218} 1 backslash {\u218} 0 {}

% testparser {{*}\u218} 7
- \{*\}\\u218\}¾r\n 1 expand \{*\}\\u218\}¾r 12 backslash {\u218} 0 text  0 text \} 0 text  0 text  0 text ¾ 0 text  0 text  0 text  0 text r 0 text  0 text  0 {}
dgpplain2011-03-05 14:38:58
That actually demos a different bug in TclParseBackslash.
dgpplain2011-03-06 11:36:57
see 3200987
dgpplain2011-03-07 00:53:50
OK, with that bug fixed, there's no way 
a script can run into this problem.  We
can declare it "not a bug" so long as we
add a precondition for all callers of this
private routine that *(list+listLength) == `\0` .

Since most of the time, the string being parsed
is the bytes field of a Tcl_Obj, this is usually
easily satisfied.
dgpplain2011-03-07 02:53:13
Nah, it's too simple a fix not to fix it.
The only real snag is no easy way to
add a test.
dgpplain2011-03-07 03:07:44
allow_comments - 1

fixed in all open branches
Log in (anonymous is fine) to add a comment.