Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2018-11-13
21:10
[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in: 848f2df503 user: dgp tags: trunk
2018-11-09
16:42
[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in: 0b52c3617e user: dgp tags: core-8-6-9-rc
16:00
[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in: b2575c74bc user: dgp tags: core-8-5-branch
14:23 • Closed ticket [35a8f1c04a]: List command can used to read beyond bounds of input... artifact: 512d067150 user: sebres
14:19
closes [35a8f1c04a]: minimalist fix - beware of discrepancy between TclScanElement and TclConvertEle... check-in: 2ec58720e9 user: sebres tags: bug-35a8f1c04a
14:13
test case to cover bug [35a8f1c04a] check-in: d76fb9091b user: sebres tags: bug-35a8f1c04a
00:50 • Ticket [35a8f1c04a] List command can used to read beyond bounds of input sta... artifact: 8fe4b2678b user: dgp
2018-11-08
21:47 • New ticket [35a8f1c04a]. artifact: 8222f3b372 user: tuckerowens

List command can used to read beyond bounds of input

Closed / Fixed35a8f1c04a9c1610b250f97b9361c35fadc583deCreated 8 years agoUpdated 8 years ago
Descriptionwiki2018-11-08 21:47:57
I cannot say I entirely know what is going wrong, only that I know it's incorrect.

Run the following in a Tcl shell:

puts "[list {#"""}]"

It seems like the Tcl interpreter is mishandling the literal #""" inside the curly braces which results in extra data to be appended to the output. I've found through experimentation that the string must start with a # and the number of quotes (must be greater than two) is proportional to the amount of additional data which follows the output.

In trials it was common for null characters to be printed, which depending on your shell might not show up, so you may need to convert the output to hex.

Here are some examples:

 
% info tclversion
8.5
% list {#""""""""""""""""""""""""""""""""""""""""""""""""""""""}
{#""""""""""""""""""""""""""""""""""""""""""""""""""""""}  auto_index(::tcl::tm::roots) [list source [file joi
% list {#""""""""""""""""""""""""""""""""""""""""""""""""""""""}
{#""""""""""""""""""""""""""""""""""""""""""""""""""""""} tïtcl]]

% list {#""""""""""""""""""""""""""""""""""""""""""""""""""""""} {#""""""""""""""""""""""""""""""""""""""""""""""""""""""} ïHÕ Ðï % list {#""""""""""""""""""""""""""""""""""""""""""""""""""""""} {#""""""""""""""""""""""""""""""""""""""""""""""""""""""} ï

Referenced by5
  • 848f2df503[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in2018-11-13 21:10:33
  • 0b52c3617e[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in2018-11-09 16:42:37
  • b2575c74bc[35a8f1c04a] Fix bad lengths when creating string rep of some lists. check-in2018-11-09 16:00:57
  • 2ec58720e9closes [35a8f1c04a]: minimalist fix - beware of discrepancy between TclScanElement and TclConvertElement (prefer braces considering TCL_DONT_QUOTE_HASH in case of first list element) check-in2018-11-09 14:19:08
  • d76fb9091btest case to cover bug [35a8f1c04a] check-in2018-11-09 14:13:15
dgpplain2018-11-09 00:50:48
Well spotted. See this confirmation:

% string length [list {#"}]
4
% string length [list {#""}]
6
% string length [list {#"""}]
8

Contrast with:

% string length [list {#x}]
4
% string length [list {#xx}]
5
% string length [list {#xxx}]
6
sebreswiki2018-11-09 14:23:07

Nice one... Found the bug (a discrepancy between TclScanElement and TclConvertElement if not TCL_DONT_QUOTE_HASH).

Fixed in [2ec58720e9] now, branch bug-35a8f1c04a.

Log in (anonymous is fine) to add a comment.