diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-03-13 15:34:22 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-03-13 15:34:22 (GMT) |
commit | d53dfb14c7bd4b0ce8dd8b8d9ff6c26c2612fded (patch) | |
tree | 57b48f5f5c5b539aedbf068b1f0004ba76da43a6 /tests | |
parent | 131176ce2f937173892c6e7e3a78978f6e8da2b5 (diff) | |
parent | 6d7423228211f312016f0c62ce1bc86c3d3777db (diff) | |
download | tcl-d53dfb14c7bd4b0ce8dd8b8d9ff6c26c2612fded.zip tcl-d53dfb14c7bd4b0ce8dd8b8d9ff6c26c2612fded.tar.gz tcl-d53dfb14c7bd4b0ce8dd8b8d9ff6c26c2612fded.tar.bz2 |
Merge 8.6: Bug [183a1adcc0]. Buffer overflow in Tcl_UtfToExternal
Diffstat (limited to 'tests')
-rw-r--r-- | tests/encoding.test | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/encoding.test b/tests/encoding.test index cf63211..efe5a91 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -1050,6 +1050,46 @@ test encoding-28.0 {all encodings load} -body { runtests +test encoding-bug-183a1adcc0-1 {Bug [183a1adcc0] Buffer overflow Tcl_UtfToExternal} -constraints { + testencoding +} -body { + # Note - buffers are initialized to \xff + list [catch {testencoding Tcl_UtfToExternal unicode A {start end} {} 1} result] $result +} -result [list 0 [list nospace {} \xff]] + +test encoding-bug-183a1adcc0-2 {Bug [183a1adcc0] Buffer overflow Tcl_UtfToExternal} -constraints { + testencoding +} -body { + # Note - buffers are initialized to \xff + list [catch {testencoding Tcl_UtfToExternal unicode A {start end} {} 0} result] $result +} -result [list 0 [list nospace {} {}]] + +test encoding-bug-183a1adcc0-3 {Bug [183a1adcc0] Buffer overflow Tcl_UtfToExternal} -constraints { + testencoding +} -body { + # Note - buffers are initialized to \xff + list [catch {testencoding Tcl_UtfToExternal unicode A {start end} {} 2} result] $result +} -result [list 0 [list nospace {} \x00\x00]] + +test encoding-bug-183a1adcc0-4 {Bug [183a1adcc0] Buffer overflow Tcl_UtfToExternal} -constraints { + testencoding +} -body { + # Note - buffers are initialized to \xff + list [catch {testencoding Tcl_UtfToExternal unicode A {start end} {} 3} result] $result +} -result [list 0 [list nospace {} \x00\x00\xff]] + +test encoding-bug-183a1adcc0-5 {Bug [183a1adcc0] Buffer overflow Tcl_UtfToExternal} -constraints { + testencoding +} -constraints { + knownBug +} -body { + # The knownBug constraint is because test depends on TCL_UTF_MAX and + # also UtfToUtf16 assumes space required in destination buffer is + # sizeof(Tcl_UniChar) which is incorrect when TCL_UTF_MAX==4 + # Note - buffers are initialized to \xff + list [catch {testencoding Tcl_UtfToExternal unicode A {start end} {} 4} result] $result +} -result [list 0 [list ok {} [expr {$::tcl_platform(byteOrder) eq "littleEndian" ? "\x41\x00" : "\x00\x41"}]\x00\x00]] + } test encoding-29.0 {get encoding nul terminator lengths} -constraints { |