summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans@users.sourceforge.net <jan.nijtmans>2013-01-23 13:57:30 (GMT)
committernijtmans@users.sourceforge.net <jan.nijtmans>2013-01-23 13:57:30 (GMT)
commited9484dba58e1d244773f507b0bd8cfdc2a5bb37 (patch)
treebb5613f01783a22bbf47ee9d2ab9974469c242a0
parent4bef90c4ae18f12f6067e299bf8ed79c9909b5e8 (diff)
downloadtcl-ed9484dba58e1d244773f507b0bd8cfdc2a5bb37.zip
tcl-ed9484dba58e1d244773f507b0bd8cfdc2a5bb37.tar.gz
tcl-ed9484dba58e1d244773f507b0bd8cfdc2a5bb37.tar.bz2
Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because I don't want to promote people start using that.
-rw-r--r--generic/tclIndexObj.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index cc50fd3..0103cdb 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -144,7 +144,7 @@ Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr)
* returned and an error message is left in interp's result (unless
* interp is NULL). The msg argument is used in the error
* message; for example, if msg has the value "option" then the
- * error message will say something flag 'bad option "foo": must be
+ * error message will say something like 'bad option "foo": must be
* ...'
*
* Side effects:
@@ -176,6 +176,10 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags,
Tcl_Obj *resultPtr;
IndexRep *indexRep;
+ /* Protect against invalid values, like -1 or 0. */
+ if (offset < (int)sizeof(char *)) {
+ offset = (int)sizeof(char *);
+ }
/*
* See if there is a valid cached result from a previous lookup.
*/