summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2023-05-19 12:02:49 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2023-05-19 12:02:49 (GMT)
commitb0f19e41f2c3e29950af3fb586b0f7a7f9112b2c (patch)
treeb744be174ece6b694da314852f5e1143ba086c48 /generic/tclScan.c
parentfea912c676a71b362b8c7d77e3f4242e374de1bb (diff)
parente47cbdc798e9744e9a89840e9ace30186872a762 (diff)
downloadtcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.zip
tcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.tar.gz
tcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.tar.bz2
merge core-8-branch
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r--generic/tclScan.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index c200fa0..f332d24 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -306,7 +306,7 @@ ValidateFormat(
* format string.
*/
- value = strtoul(format-1, &end, 10); /* INTL: "C" locale. */
+ unsigned long ul = strtoul(format-1, &end, 10); /* INTL: "C" locale. */
if (*end != '$') {
goto notXpg;
}
@@ -316,17 +316,20 @@ ValidateFormat(
if (gotSequential) {
goto mixedXPG;
}
- objIndex = value - 1;
- if ((objIndex < 0) || (numVars && (objIndex >= numVars))) {
+ if (ul == 0 || ul >= INT_MAX) {
+ goto badIndex;
+ }
+ objIndex = (int) ul - 1;
+ if (numVars && (objIndex >= numVars)) {
goto badIndex;
} else if (numVars == 0) {
/*
* In the case where no vars are specified, the user can
* specify %9999$ legally, so we have to consider special
- * rules for growing the assign array. 'value' is guaranteed
- * to be > 0.
+ * rules for growing the assign array. 'ul' is guaranteed
+ * to be > 0 and < INT_MAX as per checks above.
*/
- xpgSize = (xpgSize > value) ? xpgSize : value;
+ xpgSize = (xpgSize > (int)ul) ? xpgSize : (int)ul;
}
goto xpgCheckDone;
}