summaryrefslogtreecommitdiffstats
path: root/tests/encoding.test
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-03-13 13:44:35 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-03-13 13:44:35 (GMT)
commit6d7423228211f312016f0c62ce1bc86c3d3777db (patch)
tree5552f8d545692c0d0039689aafd7c3c0b9da2050 /tests/encoding.test
parent93bf87ed859e04b2fc9b197239ad6838e761e85d (diff)
downloadtcl-6d7423228211f312016f0c62ce1bc86c3d3777db.zip
tcl-6d7423228211f312016f0c62ce1bc86c3d3777db.tar.gz
tcl-6d7423228211f312016f0c62ce1bc86c3d3777db.tar.bz2
Bug [183a1adcc0]. Buffer overflow in Tcl_UtfToExternal
Diffstat (limited to 'tests/encoding.test')
-rw-r--r--tests/encoding.test35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/encoding.test b/tests/encoding.test
index f6f9abc..26efb19 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -739,6 +739,41 @@ 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
+} -body {
+ # 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]]
+
}
# cleanup