From 01501cb37ad2ea7f8f79ec764861ad9f30c288db Mon Sep 17 00:00:00 2001 From: patthoyts Date: Mon, 24 Mar 2008 03:05:06 +0000 Subject: Backported fix for #1923966 --- ChangeLog | 5 +++++ generic/tclBinary.c | 6 ++++-- tests/binary.test | 20 +++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e4bc52..3c2e703 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-24 Pat Thoyts + + * generic/tclBinary.c: bug #1923966 - crash in binary format + * tests/binary.test: Added tests for the above crash condition. + 2008-03-11 Daniel Steffen * macosx/tclMacOSXNotify.c: avoid using CoreFoundation after fork() on diff --git a/generic/tclBinary.c b/generic/tclBinary.c index b5bd3ff..fb47015 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBinary.c,v 1.13.2.5 2007/06/30 13:56:23 dkf Exp $ + * RCS: @(#) $Id: tclBinary.c,v 1.13.2.6 2008/03/24 03:05:07 patthoyts Exp $ */ #include "tclInt.h" @@ -793,7 +793,9 @@ Tcl_BinaryObjCmd(dummy, interp, objc, objv) break; } if ((count == 0) && (cmd != '@')) { - arg++; + if (cmd != 'x') { + arg++; + } continue; } switch (cmd) { diff --git a/tests/binary.test b/tests/binary.test index fb137db..d06907e 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: binary.test,v 1.11.2.4 2006/04/05 15:17:06 dgp Exp $ +# RCS: @(#) $Id: binary.test,v 1.11.2.5 2008/03/24 03:05:07 patthoyts Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -549,6 +549,24 @@ test binary-15.3 {Tcl_BinaryObjCmd: format} { test binary-15.4 {Tcl_BinaryObjCmd: format} { binary format a*X3x3a* "foo" "z" } \x00\x00\x00z +test binary-15.5 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x0s 1 +} \x01\x00 +test binary-15.6 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x0ss 1 1 +} \x01\x00\x01\x00 +test binary-15.5 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x0s 1 +} \x01\x00 +test binary-15.6 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x0ss 1 1 +} \x01\x00\x01\x00 +test binary-15.7 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x1s 1 +} \x00\x01\x00 +test binary-15.8 {Tcl_BinaryObjCmd: format - bug #1923966} { + binary format x1ss 1 1 +} \x00\x01\x00\x01\x00 test binary-16.1 {Tcl_BinaryObjCmd: format} { binary format a*X*a "foo" "z" -- cgit v0.12