diff options
author | patthoyts <patthoyts@noemail.net> | 2009-12-29 01:43:22 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@noemail.net> | 2009-12-29 01:43:22 (GMT) |
commit | ea67a772cbf62abd725b8584fd2f7a1df280dad1 (patch) | |
tree | 7a0e77d1cddf3fbfe3946789b0f5f0701675eccf /generic/tclBinary.c | |
parent | f5bd36c11ea607f061a2c942d6962c5f3dca68b0 (diff) | |
download | tcl-ea67a772cbf62abd725b8584fd2f7a1df280dad1.zip tcl-ea67a772cbf62abd725b8584fd2f7a1df280dad1.tar.gz tcl-ea67a772cbf62abd725b8584fd2f7a1df280dad1.tar.bz2 |
Handle completely invalid input to the decode methods [Bug 2922555]
FossilOrigin-Name: 7cac795579188e6c1a5ea11e8d92dba45ec56a2c
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 75b3ca2..042cbed 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.58 2009/12/11 23:10:47 nijtmans Exp $ + * RCS: @(#) $Id: tclBinary.c,v 1.59 2009/12/29 01:43:23 patthoyts Exp $ */ #include "tclInt.h" @@ -2309,6 +2309,7 @@ BinaryDecodeHex( *cursor++ = UCHAR(value); value = 0; } + if (cut > size) cut = size; Tcl_SetByteArrayLength(resultObj, cursor - begin - cut); Tcl_SetObjResult(interp, resultObj); return TCL_OK; @@ -2515,6 +2516,7 @@ BinaryDecodeUu( *cursor++ = (((d[2] - 0x20) & 0x3f) << 6) | (((d[3] - 0x20) & 0x3f)); } + if (cut > size) cut = size; Tcl_SetByteArrayLength(resultObj, cursor - begin - cut); Tcl_SetObjResult(interp, resultObj); return TCL_OK; @@ -2620,6 +2622,7 @@ BinaryDecode64( *cursor++ = UCHAR((value >> 8) & 0xff); *cursor++ = UCHAR(value & 0xff); } + if (cut > size) cut = size; Tcl_SetByteArrayLength(resultObj, cursor - begin - cut); Tcl_SetObjResult(interp, resultObj); return TCL_OK; |