summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-05-23 12:25:07 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-05-23 12:25:07 (GMT)
commitd23fe52664cbef62956cc8ba4e689b9873992b0c (patch)
tree216cec543ae24c904877986891d6388f6655aed8 /generic/tclBinary.c
parent674ed242bc26f2a7d7e773dfd456fd95164f8bac (diff)
parent12e58887228678c386542cde6966948245f7491d (diff)
downloadtcl-d23fe52664cbef62956cc8ba4e689b9873992b0c.zip
tcl-d23fe52664cbef62956cc8ba4e689b9873992b0c.tar.gz
tcl-d23fe52664cbef62956cc8ba4e689b9873992b0c.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index a3e5071..72f1498 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -1743,7 +1743,15 @@ GetFormatSpec(
(*formatPtr)++;
*countPtr = BINARY_ALL;
} else if (isdigit(UCHAR(**formatPtr))) { /* INTL: digit */
- *countPtr = strtoul(*formatPtr, (char **) formatPtr, 10);
+ unsigned long int count;
+
+ errno = 0;
+ count = strtoul(*formatPtr, (char **) formatPtr, 10);
+ if (errno || (count > (unsigned long) INT_MAX)) {
+ *countPtr = INT_MAX;
+ } else {
+ *countPtr = (int) count;
+ }
} else {
*countPtr = BINARY_NOCOUNT;
}