diff options
author | dgp <dgp@users.sourceforge.net> | 2018-03-09 21:18:19 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-03-09 21:18:19 (GMT) |
commit | cd4e0ec5deffef9dbc4331768ca660fef4590501 (patch) | |
tree | 0cdf856871de94cc8600b76014a998f815070896 | |
parent | 954522812e2e6644f38fa1ee44ce949a6c83a9d1 (diff) | |
download | tcl-cd4e0ec5deffef9dbc4331768ca660fef4590501.zip tcl-cd4e0ec5deffef9dbc4331768ca660fef4590501.tar.gz tcl-cd4e0ec5deffef9dbc4331768ca660fef4590501.tar.bz2 |
Restore safety for legacy bytecode.
-rw-r--r-- | generic/tclExecute.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 5d29db9..151a899 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5241,7 +5241,14 @@ TEBCresume( /* Decode index value operands. */ + /* assert ( toIdx != TCL_INDEX_AFTER); + * + * Extra safety for legacy bytecodes: + */ + if (toIdx == TCL_INDEX_AFTER) { + toIdx = TCL_INDEX_END; + } if ((toIdx == TCL_INDEX_BEFORE) || (fromIdx == TCL_INDEX_AFTER)) { goto emptyList; @@ -5254,8 +5261,14 @@ TEBCresume( } assert ( toIdx >= 0 && toIdx < objc); + /* assert ( fromIdx != TCL_INDEX_BEFORE ); - assert ( fromIdx != TCL_INDEX_AFTER); + * + * Extra safety for legacy bytecodes: + */ + if (fromIdx == TCL_INDEX_BEFORE) { + fromIdx = TCL_INDEX_START; + } fromIdx = TclIndexDecode(fromIdx, objc - 1); if (fromIdx < 0) { @@ -5631,8 +5644,18 @@ TEBCresume( /* Decode index operands. */ + /* assert ( toIdx != TCL_INDEX_BEFORE ); assert ( toIdx != TCL_INDEX_AFTER); + * + * Extra safety for legacy bytecodes: + */ + if (toIdx == TCL_INDEX_BEFORE) { + goto emptyRange; + } + if (toIdx == TCL_INDEX_AFTER) { + toIdx = TCL_INDEX_END; + } toIdx = TclIndexDecode(toIdx, length - 1); if (toIdx < 0) { @@ -5643,8 +5666,18 @@ TEBCresume( assert ( toIdx >= 0 && toIdx < length ); + /* assert ( fromIdx != TCL_INDEX_BEFORE ); assert ( fromIdx != TCL_INDEX_AFTER); + * + * Extra safety for legacy bytecodes: + */ + if (fromIdx == TCL_INDEX_BEFORE) { + fromIdx = TCL_INDEX_START; + } + if (fromIdx == TCL_INDEX_AFTER) { + goto emptyRange; + } fromIdx = TclIndexDecode(fromIdx, length - 1); if (fromIdx < 0) { |