summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2009-12-29 01:43:23 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2009-12-29 01:43:23 (GMT)
commit59172cf14f46e7f765d6bcce585b735629d1873f (patch)
tree7a0e77d1cddf3fbfe3946789b0f5f0701675eccf /generic/tclBinary.c
parent4f253f35d890f5474c5652070916df0cee97a89b (diff)
downloadtcl-59172cf14f46e7f765d6bcce585b735629d1873f.zip
tcl-59172cf14f46e7f765d6bcce585b735629d1873f.tar.gz
tcl-59172cf14f46e7f765d6bcce585b735629d1873f.tar.bz2
Handle completely invalid input to the decode methods [Bug 2922555]
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c5
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;