diff options
author | dkf <dkf@noemail.net> | 2009-12-30 22:26:42 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2009-12-30 22:26:42 (GMT) |
commit | c2bc3b7b8a74e75e57a10129ce2483526268017e (patch) | |
tree | 855cb8a0b5062bf4f178a9eba1c51d73da9e0609 /library | |
parent | 2b89ab3affceef83096a6116ca627dc5f60fb2fb (diff) | |
download | tcl-c2bc3b7b8a74e75e57a10129ce2483526268017e.zip tcl-c2bc3b7b8a74e75e57a10129ce2483526268017e.tar.gz tcl-c2bc3b7b8a74e75e57a10129ce2483526268017e.tar.bz2 |
[Bug 2923613]: Make the safer [source] handle a [return] at the end of the
file correctly.
FossilOrigin-Name: 52080bfb5dcd90ba0cba4c7d316b5d1cb91948ed
Diffstat (limited to 'library')
-rw-r--r-- | library/safe.tcl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/library/safe.tcl b/library/safe.tcl index eaae00d..7c81f92 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: safe.tcl,v 1.36 2009/12/23 11:17:33 dkf Exp $ +# RCS: @(#) $Id: safe.tcl,v 1.37 2009/12/30 22:26:43 dkf Exp $ # # The implementation is based on namespaces. These naming conventions are @@ -842,7 +842,7 @@ proc ::safe::AliasSource {slave args} { # because we want to control [info script] in the slave so information # doesn't leak so much. [Bug 2913625] set old [::interp eval $slave {info script}] - if {[catch { + set code [catch { set f [open $realfile] fconfigure $f -eofchar \032 if {$encoding ne ""} { @@ -852,13 +852,15 @@ proc ::safe::AliasSource {slave args} { close $f ::interp eval $slave [list info script $file] ::interp eval $slave $contents - } msg]} { - catch {interp eval $slave [list info script $old]} + } msg opt] + catch {interp eval $slave [list info script $old]} + # Note that all non-errors are fine result codes from [source], so we must + # take a little care to do it properly. [Bug 2923613] + if {$code == 1} { Log $slave $msg return -code error "script error" } - catch {interp eval $slave [list info script $old]} - return $msg + return -code $code -options $opt $msg } # AliasLoad is the target of the "load" alias in safe interpreters. |