Artifacts Associated With Ticket 3371644
Ticket change [bd40b25d40] (rid 101879) by thommey on 2011-07-19 17:54:37:
- assignee initialized to: "hobbs"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The testcode at http://paste.tclers.tk/2502 causes tcl8.5.10 (release) and current head to segfault (dereferences garbage pointer). gdb output: Program received signal SIGSEGV, Segmentation fault. 0xb7f6e493 in TclConvertElement ( src=0x8074d0d "O\270\267xO\270\267\200O\270\267`O\270\267", length=-2, dst=0x805fa60 "\\#test\\\\\\\\\\\\", flags=4) at /xtra/src/tcl8.5.10/unix/../generic/tclUtil.c:1363 1363*p = *src; (gdb) p p $1 = 0x808d000 <Address 0x808d000 out of bounds> (gdb) bt full #0 0xb7f6e493 in TclConvertElement ( src=0x8074d0d "O\270\267xO\270\267\200O\270\267`O\270\267", length=-2, dst=0x805fa60 "\\#test\\\\\\\\\\\\", flags=4) at /usr/src/tcl8.5.10/unix/../generic/tclUtil.c:1363 conversion = 4 p = 0x808d000 <Address 0x808d000 out of bounds> #1 0xb7f6e24a in Tcl_ConvertCountedElement ( src=0x808d000 <Address 0x808d000 out of bounds>, length=-1, dst=0x805fa60 "\\#test\\\\\\\\\\\\", flags=4) at /usr/src/tcl8.5.10/unix/../generic/tclUtil.c:1202 numBytes = -1208557020 #2 0xb7f6e21e in Tcl_ConvertElement ( src=0x8074d0d "O\270\267xO\270\267\200O\270\267`O\270\267", dst=0x808d000 <Address 0x808d000 out of bounds>, flags=79) at /usr/src/tcl8.5.10/unix/../generic/tclUtil.c:1171 No locals. #3 0x080487f8 in main (argc=1, argv=0xbffffa14) at test2.c:20 flags = 4 size = 12 dst = 0x805fa60 "\\#test\\\\\\\\\\\\" src = 0x8048900 "#test\\\\\\" interp = 0x804c9e0 Valgrind: ==6136== Invalid write of size 1 ==6136== at 0x4137493: TclConvertElement (tclUtil.c:1363) ==6136== by 0x4137249: Tcl_ConvertCountedElement (tclUtil.c:1202) ==6136== by 0x413721D: Tcl_ConvertElement (tclUtil.c:1171) ==6136== by 0x80487F7: main (test2.c:20) ==6136== Address 0x437e16d is 0 bytes after a block of size 13 alloc'd ==6136== at 0x4025018: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==6136== by 0x80487C2: main (test2.c:18) - foundin initialized to: "obsolete: 8.5.10"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "thommey"
- subsystem initialized to: "11. Conversions from String"
- title initialized to: "Segfault in Tcl_ConvertElement()"
- type initialized to: "Bug"
Ticket change [695fc838fd] (rid 103237) by ferrieux on 2011-07-20 01:02:12:
- icomment:
Also repro on 8.6 HEAD. There, line 1264 of tclUtil.c has a suspicious "length--" applied to a length of -1. Patch below fixes it and passes the test suite. Index: generic/tclUtil.c =================================================================== --- generic/tclUtil.c +++ generic/tclUtil.c @@ -1259,11 +1259,11 @@ if (conversion == CONVERT_ESCAPE) { p[0] = '\\'; p[1] = '#'; p += 2; src++; - length--; + if (length >=0) length--; } else { conversion = CONVERT_BRACE; } } - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [5a65d1a58b] (rid 118135) by ferrieux on 2011-07-20 01:23:01:
- icomment:
Fixed in 8.6 HEAD. Leaving open until someone backcommits to 8.5 (properly :P)
- login: "ferrieux"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- username: "ferrieux"
- icomment:
Ticket change [2c5718db1d] (rid 118887) by dgp on 2011-07-20 02:40:48:
- assignee changed to: "dgp"
- closedate changed to: "2011-07-19T19:40:48"
- closer changed to: "dgp"
- icomment:
allow_comments - 1
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "dgp"