Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-08-05
10:46 • Closed ticket [584051ffff]: Tcl_Parse* ignore length argument plus 8 other c... artifact: 0fb18534ab user: dgp
2002-07-24
21:25 • Ticket [584051ffff]: 4 changes artifact: ad45316b65 user: dgp
2002-07-20
06:16 • Ticket [584051ffff]: 5 changes artifact: 06d738b747 user: dgp
05:43 • Ticket [584051ffff]: 5 changes artifact: 07d1fb9617 user: dgp
2002-07-19
22:24 • New ticket [584051ffff]. artifact: 0bc39e7ba9 user: dgp

Tcl_Parse* ignore length argument

Closed / Fixed584051ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-07-19 22:24:01
In the tcltest executable, try:

testparsevarname {$a(f_} 4 0

This should try to parse the first 4
characters of the string as a 
variable name.  It should return
an error message "missing )"
because the first 4 characters
so not spell out a legal variable
name.

However, unless the caller has
replaced _ with \0, Tcl_ParseVarName
is quite happy to go marching
through memory looking for that
close paren.
dgpplain2002-07-20 05:43:57
Logged In: YES 
user_id=80530


Tcl_ParseQuotedString has a similar
problem, although there's no special
command in tcltest for testing it.
Imagine there was and try:

testparsequotedstring {"a_} 2 0

It will also escape into memory
beyond length.

These both boil down to an
assumption by ParseTokens
that *(parsePtr->end) is a NUL
byte.  Either all callers of ParseTokens
need to verify that is true, or ParseTokens
should set that up itself, or (yuk!) the
terminating NUL requirement would
have to be documented and depend
on callers to do it.
dgpplain2002-07-20 06:16:59
Logged In: YES 
user_id=80530


Tcl_ParseBraces has similar trouble.
Imagine the test command:

testparsebraces "\{a\\\n\t\t foo bar}" 3 0

T_PB should examine the 3 characters
{ a \
and return the error "missing close-brace".
Instead it gets caught up trying to do
backslash substitution, and scans all the
way to the close-brace.  It would keep
going through all memory until it found
one.

Fixes: 1) Document T_PB as requiring
NUL-terminated string (YUK!); or
2) Have T_PB set the NUL it needs 
on entry, and restore on exit; or
3) Have T_PB call a different form of
Tcl_UtfBackslash that can properly
operate on counted strings.
dgpplain2002-07-24 21:25:36
Logged In: YES 
user_id=80530


Adopting Patch 585105 is one way to
fix these bugs.
dgpplain2002-08-05 10:46:29
Logged In: YES 
user_id=80530

fixed by acceptance of 585105
Log in (anonymous is fine) to add a comment.