From b4745088b1dad2c57d04048297da3e302f3bf011 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 7 Jan 2019 01:11:32 +0000 Subject: cherry-pick [3e4d907d8e] from 8.6: prevent buffer overrun in fast_s_mp_mul_digs(). --- libtommath/bn_fast_s_mp_mul_digs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c index ab157b9..4cc98ce 100644 --- a/libtommath/bn_fast_s_mp_mul_digs.c +++ b/libtommath/bn_fast_s_mp_mul_digs.c @@ -87,7 +87,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) { register mp_digit *tmpc; tmpc = c->dp; - for (ix = 0; ix < pa+1; ix++) { + for (ix = 0; ix < pa; ix++) { /* now extract the previous digit [below the carry] */ *tmpc++ = W[ix]; } -- cgit v0.12 From 1d20d5be0d4e895553cfa9df6ea4769a4ed309c9 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 8 Jan 2019 13:29:29 +0000 Subject: bug [cc1e91552c]: added test cases showing the regression (expansion & lrange) --- tests/basic.test | 4 ++++ tests/lrange.test | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/tests/basic.test b/tests/basic.test index 865814a..137ad53 100644 --- a/tests/basic.test +++ b/tests/basic.test @@ -962,6 +962,10 @@ test basic-48.23.$noComp {expansion: handle return codes} -constraints $constrai unset res t } -result {0 10 1 Hejsan} +test basic-48.24.$noComp {expansion: empty not canonical list, regression test, bug [cc1e91552c]} $constraints { + run {list [list {*}{ }] [list {*}[format %c 32]] [list {*}[set a { }]]} +} [lrepeat 3 {}] + } ;# End of noComp loop test basic-49.1 {Tcl_EvalEx: verify TCL_EVAL_GLOBAL operation} testevalex { diff --git a/tests/lrange.test b/tests/lrange.test index ba10354..4ba645d 100644 --- a/tests/lrange.test +++ b/tests/lrange.test @@ -108,6 +108,16 @@ test lrange-3.6 {compiled with calculated indices, end out of range (after end)} list [lrange {a b c} 1 end+1] [lrange {a b c} 1+0 2+1] [lrange {a b c} 1 end+1] [lrange {a b c} end-1 3+1] } [lrepeat 4 {b c}] +test lrange-3.7a {compiled on empty not canonical list (with static and dynamic indices), regression test, bug [cc1e91552c]} { + list [lrange { } 0 1] [lrange [format %c 32] 0 1] [lrange [set a { }] 0 1] \ + [lrange { } 0-1 end+1] [lrange [format %c 32] 0-1 end+1] [lrange $a 0-1 end+1] +} [lrepeat 6 {}] +test lrange-3.7b {not compiled on empty not canonical list (with static and dynamic indices), regression test, bug [cc1e91552c]} { + set cmd lrange + list [$cmd { } 0 1] [$cmd [format %c 32] 0 1] [$cmd [set a { }] 0 1] \ + [$cmd { } 0-1 end+1] [$cmd [format %c 32] 0-1 end+1] [$cmd $a 0-1 end+1] +} [lrepeat 6 {}] + # cleanup ::tcltest::cleanupTests -- cgit v0.12 From 97ef187e5b07fc14f06183a402e5d0f286854913 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 8 Jan 2019 13:35:03 +0000 Subject: closes [cc1e91552c]: fixes lrange instruction on empty list, return original list only if it is canonical (otherwise new list object) --- generic/tclExecute.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index bb96a9e..cd78adf 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -5237,8 +5237,12 @@ TEBCresume( /* Every range of an empty list is an empty list */ if (objc == 0) { - TRACE_APPEND(("\n")); - NEXT_INST_F(9, 0, 0); + /* avoid return of not canonical list (e. g. spaces in string repr.) */ + if (ListObjIsCanonical(valuePtr)) { + TRACE_APPEND(("\n")); + NEXT_INST_F(9, 0, 0); + } + goto emptyList; } /* Decode index value operands. */ -- cgit v0.12 From 9ad3d4b7b182e5ef54ebddd3c84b8eefd803b86c Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 8 Jan 2019 14:39:59 +0000 Subject: amend to [a87460dbd4], added clean-up to avoid error {can't set "a(x)": variable isn't array} on next iteration of noComp loop. --- tests/basic.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/basic.test b/tests/basic.test index 137ad53..089a62b 100644 --- a/tests/basic.test +++ b/tests/basic.test @@ -962,9 +962,11 @@ test basic-48.23.$noComp {expansion: handle return codes} -constraints $constrai unset res t } -result {0 10 1 Hejsan} -test basic-48.24.$noComp {expansion: empty not canonical list, regression test, bug [cc1e91552c]} $constraints { +test basic-48.24.$noComp {expansion: empty not canonical list, regression test, bug [cc1e91552c]} -constraints $constraints -setup { + unset -nocomplain a +} -body { run {list [list {*}{ }] [list {*}[format %c 32]] [list {*}[set a { }]]} -} [lrepeat 3 {}] +} -result [lrepeat 3 {}] -cleanup {unset -nocomplain a} } ;# End of noComp loop -- cgit v0.12 From cc6df875d61dde74a9824a0064deba8b52703f65 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 8 Jan 2019 18:15:30 +0000 Subject: fixed missing dependency in test-cases "*io-60.1" (constraint-related) - missed load of tcltest-library in sub-process --- tests/chanio.test | 8 ++++++-- tests/io.test | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 6408f50..230d37c 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -30,8 +30,11 @@ namespace eval ::tcl::test::io { variable msg variable expected - loadTestedCommands - catch [list package require -exact Tcltest [info patchlevel]] + catch { + ::tcltest::loadTestedCommands + package require -exact Tcltest [info patchlevel] + set ::tcltestlib [lindex [package ifneeded Tcltest [info patchlevel]] 1] + } package require tcltests testConstraint testbytestring [llength [info commands testbytestring]] @@ -7446,6 +7449,7 @@ test chan-io-59.1 {Thread reference of channels} {testmainthread testchannel} { test chan-io-60.1 {writing illegal utf sequences} {openpipe fileevent testbytestring} { # This test will hang in older revisions of the core. set out [open $path(script) w] + chan puts $out "catch {load $::tcltestlib Tcltest}" chan puts $out { chan puts [testbytestring \xe2] exit 1 diff --git a/tests/io.test b/tests/io.test index 996e125..fe1052a 100644 --- a/tests/io.test +++ b/tests/io.test @@ -29,8 +29,11 @@ namespace eval ::tcl::test::io { variable msg variable expected - loadTestedCommands - catch [list package require -exact Tcltest [info patchlevel]] + catch { + ::tcltest::loadTestedCommands + package require -exact Tcltest [info patchlevel] + set ::tcltestlib [lindex [package ifneeded Tcltest [info patchlevel]] 1] + } package require tcltests testConstraint testbytestring [llength [info commands testbytestring]] @@ -8270,6 +8273,7 @@ test io-60.1 {writing illegal utf sequences} {openpipe fileevent testbytestring} # This test will hang in older revisions of the core. set out [open $path(script) w] + puts $out "catch {load $::tcltestlib Tcltest}" puts $out { puts [testbytestring \xe2] exit 1 -- cgit v0.12