From 401b464a4d657490333388130b1fc7ae0d212646 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 12 Dec 2021 17:59:11 +0000 Subject: Fix [ac6792195d]: avoid signed integer overflow in BinaryEncodeUu() --- generic/tclBinary.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 0f8f77e..0296770 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -69,7 +69,7 @@ static void UpdateStringOfByteArray(Tcl_Obj *listPtr); static void DeleteScanNumberCache(Tcl_HashTable *numberCachePtr); static int NeedReversing(int format); static void CopyNumber(const void *from, void *to, - unsigned length, int type); + unsigned int length, int type); /* Binary ensemble commands */ static Tcl_ObjCmdProc BinaryFormatCmd; static Tcl_ObjCmdProc BinaryScanCmd; @@ -1649,7 +1649,7 @@ GetFormatSpec( (*formatPtr)++; *countPtr = BINARY_ALL; } else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */ - unsigned long int count; + unsigned long count; errno = 0; count = strtoul(*formatPtr, (char **) formatPtr, 10); @@ -2599,7 +2599,8 @@ BinaryEncodeUu( { Tcl_Obj *resultObj; unsigned char *data, *start, *cursor; - int offset, count, rawLength, n, i, j, bits, index; + int offset, count, rawLength, i, j, bits, index; + unsigned int n; int lineLength = 61; const unsigned char SingleNewline[] = { UCHAR('\n') }; const unsigned char *wrapchar = SingleNewline; -- cgit v0.12