summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-05-02 16:48:57 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-05-02 16:48:57 (GMT)
commit2dccd2a5670532686cbe9da74ccf8e2ce591a20b (patch)
tree9da7012e4e94d3535ea236e4eb0f171ec3f349eb /generic/tclScan.c
parent6c4b78cfa8c06ea5963591778902da74850d1985 (diff)
parentdf75b9195608f60545ced2c165c87ad65288c66d (diff)
downloadtcl-2dccd2a5670532686cbe9da74ccf8e2ce591a20b.zip
tcl-2dccd2a5670532686cbe9da74ccf8e2ce591a20b.tar.gz
tcl-2dccd2a5670532686cbe9da74ccf8e2ce591a20b.tar.bz2
Merge 8.6 - [ab123cfd3d] and [784befb0ba]
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;
}