[Bug 9186] sha256sum in a script causes following commands to be executed twice

bugzilla at busybox.net bugzilla at busybox.net
Fri Aug 19 16:43:46 UTC 2016


Denys Vlasenko <vda.linux at googlemail.com> changed:

           What    |Removed                     |Added
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #2 from Denys Vlasenko <vda.linux at googlemail.com> ---
Fixed in git, please try it:

commit 215b0ca6e4fe466c6942d21a1bba62d97f2d5e5d
Author: Denys Vlasenko <vda.linux at googlemail.com>
Date:   Fri Aug 19 18:23:56 2016 +0200

    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
    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 <eof> 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.

You are receiving this mail because:
You are on the CC list for the bug.

More information about the busybox-cvs mailing list