From 215b0ca6e4fe466c6942d21a1bba62d97f2d5e5d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 19 Aug 2016 18:23:56 +0200 Subject: hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186 Run this in a "sh SCRIPT": sha256sum /dev/null echo END sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s. By this time, entire script is read, and buffered in a FILE object from fopen("SCRIPT"). But fgetc() did not consume entire input. exit() lseeks back by -9 bytes, from to 'e' in 'echo'. (this may be libc-specific). This change of fd position *is shared with the parent*! Now parent can read more, and it thinks there is another "echo END". End result: two "echo END"s are run. Fix this by _exit()ing instead. Signed-off-by: Denys Vlasenko --- shell/hush_test/run-all | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'shell/hush_test/run-all') diff --git a/shell/hush_test/run-all b/shell/hush_test/run-all index 64a7abc47..837b3f7da 100755 --- a/shell/hush_test/run-all +++ b/shell/hush_test/run-all @@ -64,11 +64,12 @@ do_test() echo -n "$1/$x:" ( "$THIS_SH" "./$x" >"$name.xx" 2>&1 + r=$? # filter C library differences sed -i \ -e "/: invalid option /s:'::g" \ "$name.xx" - test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77 + test $r -eq 77 && rm -f "../$1-$x.fail" && exit 77 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" ) case $? in -- cgit v1.2.3