busybox/libbb
Denys Vlasenko 215b0ca6e4 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 <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.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
..
appletlib.c hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186 2016-08-19 18:43:06 +02:00
ask_confirmation.c
auto_string.c libbb: auto_string() for efficient handling of temporary malloced stirngs 2015-10-09 17:59:56 +02:00
bb_askpass.c use auto_string() where appropriate to kill a few statics 2015-10-09 18:16:40 +02:00
bb_bswap_64.c
bb_do_delay.c
bb_pwd.c libpwdgrp: rewritten to use malloced implementation 2015-01-02 21:37:59 +01:00
bb_qsort.c
bb_strtod.c
bb_strtonum.c libbb/bb_strtonum: always set end ptr, even on error return 2011-12-22 13:00:32 +01:00
bbunit.c unit-tests: remove code depending on WANT_TIMING 2015-08-17 17:01:49 +02:00
change_identity.c libbb: Enable support for !CONFIG_MULTIUSER 2015-05-12 23:59:57 +02:00
chomp.c
common_bufsiz.c libbb: constify *bb_common_bufsiz1 (if it is compiled to be a pointer) 2016-04-21 21:47:45 +02:00
compare_string_array.c libbb: another unit test for is_suffixed_with 2015-09-15 23:38:01 +02:00
concat_path_file.c
concat_subpath_file.c
Config.src lineedit: FEATURE_REVERSE_SEARCH should not depend on SAVEHISTORY 2015-10-30 21:39:19 +01:00
copy_file.c cp: fix -i for POSIX mode. Closes 9106 2016-08-13 23:23:48 +02:00
copyfd.c libbb: use sendfile() to copy data between file descriptors 2014-11-27 23:31:58 +01:00
correct_password.c ftpd: add optional support for authentication 2014-08-05 21:57:18 +02:00
crc32.c
default_error_retval.c
device_open.c
die_if_bad_username.c die_if_bad_username: tighten up a bit 2011-08-09 04:05:13 +02:00
dump.c hexdump: don't unconditionally limit the usable address range 2013-03-27 15:15:33 +01:00
endofname.c move endofname() to libbb 2013-02-26 00:36:53 +01:00
executable.c nsenter,unshare: share common code; fix a bug of not closing all fds 2016-04-02 18:06:24 +02:00
fclose_nonstdin.c sed: open input files sequentially to avoid EMFILE 2013-11-28 03:14:16 +01:00
fflush_stdout_and_exit.c remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds 2015-10-09 16:42:57 +02:00
fgets_str.c
find_mount_point.c find_mount_point: fix find_mount_point for char devices 2012-01-18 01:49:11 +01:00
find_pid_by_name.c
find_root_device.c
full_write.c
get_console.c
get_cpu_count.c
get_last_path_component.c find: cater for libc w/o FNM_CASEFOLD 2011-05-23 00:40:54 +02:00
get_line_from_file.c libbb: split bb_get_chunk_from_file and bb_get_chunk_with_continuation 2011-06-17 03:37:43 +02:00
get_shell_name.c mark get_shell_name FAST_FUNC 2012-10-03 09:42:21 +02:00
get_volsize.c
getopt32.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
getpty.c script: make it work even if fd 0 is closed 2014-03-16 12:34:53 +01:00
hash_md5_sha.c md5sum: code shrink 2015-10-07 19:17:01 +02:00
hash_md5prime.c regularize options which control size/speed trade 2011-09-10 13:25:57 +02:00
herror_msg.c
human_readable.c du: extra compat: with -k and -m, round sizes up 2015-10-15 21:33:34 +02:00
in_ether.c Removes stray empty line from code 2015-07-13 03:25:46 +02:00
inet_cksum.c inet_cksum: big-endian fix 2011-09-08 10:59:26 +02:00
inet_common.c libbb: make INET[6]_rresolve use sockaddr2{host,dotted}_noport 2015-02-03 12:07:40 +01:00
inode_hash.c du, copy_file: fix file matching on cramfs. Closes 5456 2014-02-25 15:27:58 +01:00
isdirectory.c libbb: remove is_directory's argument which is always NULL 2011-12-18 03:27:46 +01:00
Kbuild.src randomconfig fixes 2 2016-06-19 21:54:04 +02:00
kernel_version.c tidy up strtok use 2015-10-23 18:43:16 +02:00
last_char_is.c
lineedit_ptr_hack.c
lineedit.c lineedit: trivial codeshrink for vi-mode 2016-08-14 23:30:29 +02:00
llist.c main: free suid_config list after use 2011-05-16 12:21:31 +02:00
logenv.c zcip: Add environment variable for overriding log functionality 2014-11-04 12:19:04 +01:00
login.c libbb: introduce and use strftime_[YYYYMMDD]HHMMSS() 2013-03-29 12:30:33 +01:00
loop.c libbb/loop: don't try to re-use existing loop device 2015-02-07 19:13:57 +01:00
make_directory.c Add conditional support for -v / --verbose 2014-05-19 16:23:50 +02:00
makedev.c
match_fstype.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
messages.c libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it 2016-04-21 17:39:11 +02:00
missing_syscalls.c Resolve linker issues with Android API 21 (dprintf, tcdrain) 2015-12-17 16:42:41 +01:00
mode_string.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
mtab.c
nuke_str.c fix failures found by randomconfig builds 2013-12-31 23:22:36 +01:00
obscure.c unit-tests: implement the unit-testing framework 2014-06-22 16:30:41 +02:00
parse_config.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
parse_mode.c libbb: more compact API for bb_parse_mode() 2015-10-07 17:55:33 +02:00
percent_decode.c wget: URL-decode user:password before base64-encoding it into auth hdr. Closes 3625. 2011-09-11 21:04:02 +02:00
perror_msg.c
perror_nomsg_and_die.c
perror_nomsg.c
pidfile.c
platform.c Bionic lacks ttyname_r; provide a workaround 2015-04-25 21:32:48 +02:00
print_flags.c
printable_string.c libbb: auto_string() for efficient handling of temporary malloced stirngs 2015-10-09 17:59:56 +02:00
printable.c Refactor catv. Move visible() from stty to libbb. 2013-07-30 06:29:42 +02:00
process_escape_sequence.c
procps.c pmap: fix bogus {no such process} comm field text 2015-10-24 03:45:57 +02:00
progress.c wget: if stderr is not a tty, progress bar shouldn't use tty-tricks 2015-10-23 02:01:38 +02:00
ptr_to_globals.c
pw_encrypt_des.c
pw_encrypt_md5.c fix assorted unused code and wrong format specs found by cppchekc (bug 6716) 2013-11-29 16:43:33 +01:00
pw_encrypt_sha.c
pw_encrypt.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
read_key.c Add comments in keyboard escape sequences table 2012-06-11 14:40:17 +02:00
read_printf.c libbb: remove unnecessary argument to nonblock_immune_read 2015-04-20 13:41:32 +02:00
read.c
README
recursive_action.c
remove_file.c Add conditional support for -v / --verbose 2014-05-19 16:23:50 +02:00
replace.c xargs: add support for -I and -i. Closes 493 2014-02-27 11:17:06 +01:00
rtc.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
run_shell.c
safe_gethostname.c sendmail: use host rather than NIS domain name for HELO 2012-04-28 17:04:19 +02:00
safe_poll.c
safe_strncpy.c
safe_write.c
selinux_common.c whitespace cleanup. no code changes 2013-01-14 15:57:44 +01:00
setup_environment.c su: do not change to home dir unless -l 2012-06-12 13:21:02 +02:00
signals.c libbb: correctness/size tweaks in signal-related helpers 2012-09-27 13:20:34 +02:00
simplify_path.c
single_argv.c basename,dirname,freeramdisk,rx,raidautorun,runsv,chvt: skip "--" argument 2011-04-11 03:58:30 +02:00
skip_whitespace.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
speed_table.c libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short. 2014-01-08 15:25:20 +01:00
str_tolower.c
strrstr.c unit-tests: implement the unit-testing framework 2014-06-22 16:30:41 +02:00
sysconf.c libbb: add sanity check in bb_arg_max() 2014-12-24 01:46:29 +01:00
time.c libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951 2016-05-31 02:50:54 +02:00
trim.c
u_signal_names.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
ubi.c whitespace and namespace cleanups 2016-04-03 22:24:51 +02:00
udp_io.c libbb: add setsockopt_foo helpers 2015-08-24 20:00:17 +02:00
unicode.c lineedit: improve Unicode handling (still buggy though) 2013-08-19 16:44:05 +02:00
update_passwd.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
utmp.c *: Switch to POSIX utmpx API 2015-04-02 23:03:46 +02:00
uuencode.c libbb: shrink base64 decoding a bit 2011-10-28 16:15:00 +02:00
vdprintf.c libbb.h: remove unused defines 2011-10-24 04:06:18 +02:00
verror_msg.c libbb: speed up error_msg functions 2016-04-03 16:55:03 +02:00
vfork_daemon_rexec.c config: disentangle PREFER_APPLETS from SH_STANDALONE and SH_NOFORK 2016-07-22 18:48:38 +02:00
warn_ignoring_args.c
wfopen_input.c
wfopen.c
write.c
xatonum_template.c whitespace fixes. no code changes 2013-01-15 13:58:01 +01:00
xatonum.c truncate: new applet 2015-03-22 17:56:38 +01:00
xconnect.c libbb: add setsockopt_foo helpers 2015-08-24 20:00:17 +02:00
xfunc_die.c remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS builds 2015-10-09 16:42:57 +02:00
xfuncs_printf.c nsenter,unshare: share common code; fix a bug of not closing all fds 2016-04-02 18:06:24 +02:00
xfuncs.c libbb: two new functions: wait_for_exitstatus(pid), xfchdir(fd) 2016-04-01 22:12:44 +02:00
xgetcwd.c
xgethostbyname.c
xreadlink.c libbb: fix a bad check for uclibc >= 0.9.31 2014-03-16 20:53:40 +01:00
xrealloc_vector.c
xregcomp.c

Please see the LICENSE file for copyright information (GPLv2)

libbb is BusyBox's utility library.  All of this stuff used to be stuffed into
a single file named utility.c.  When I split utility.c to create libbb, some of
the very oldest stuff ended up without their original copyright and licensing
information (which is now lost in the mists of time).  If you see something
that you wrote that is mis-attributed, do let me know so we can fix that up.

	Erik Andersen
	<andersen@codepoet.org>