From cd4e0ec5deffef9dbc4331768ca660fef4590501 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 9 Mar 2018 21:18:19 +0000 Subject: Restore safety for legacy bytecode. --- generic/tclExecute.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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) { -- cgit v0.12