busybox/libbb
Denys Vlasenko 41ef41b3e0 hush: fix nested redirects colliding with script fds
This necessitates switch from libc FILE api to a simple
homegrown replacement.
The change which fixes the bug here is the deleting of

	restore_redirected_FILEs();

line. It was prematurely moving (restoring) script fd#3.
The fix is: we don't even _want_ to restore scrit fds,
we are perfectly fine with them being moved.
The only reason we tried to restore them is that FILE api
did not allow moving of FILE->fd.

function                                             old     new   delta
refill_HFILE_and_getc                                  -      93     +93
hfopen                                                 -      90     +90
hfclose                                                -      66     +66
pseudo_exec_argv                                     591     597      +6
hush_main                                           1089    1095      +6
builtin_source                                       209     214      +5
save_fd_on_redirect                                  197     200      +3
setup_redirects                                      320     321      +1
fgetc_interactive                                    235     236      +1
i_peek_and_eat_bkslash_nl                             99      97      -2
expand_vars_to_list                                 1103    1100      -3
restore_redirects                                     99      52     -47
fclose_and_forget                                     57       -     -57
remember_FILE                                         63       -     -63
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 6/3 up/down: 271/-172)           Total: 99 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-24 16:54:41 +02:00
..
appletlib.c whitespace fixes 2018-07-17 15:04:17 +02:00
ask_confirmation.c xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copy 2018-04-07 15:23:10 +02:00
auto_string.c libbb: auto_string() for efficient handling of temporary malloced stirngs 2015-10-09 17:59:56 +02:00
bb_askpass.c libbb: switch bb_ask_noecho() to "mallocing" string return API 2018-04-07 15:50:30 +02:00
bb_bswap_64.c *: deinline SWAP_xE64 on 32-bit CPUs. Wins !90 bytes both on 32 and 64 bits 2010-10-18 11:40:26 +02:00
bb_cat.c fix errors found with make_single_applets.sh 2017-04-12 15:48:19 +02:00
bb_do_delay.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
bb_getgroups.c libbb: new function bb_getgroups() - allocating wrapper around getgroups() 2017-07-04 18:56:45 +02:00
bb_getsockname.c libbb: introduce and use bb_getsockname() 2018-02-11 14:55:46 +01:00
bb_pwd.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
bb_qsort.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
bb_strtod.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
bb_strtonum.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
bbunit.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
capability.c libbb: compile capability code only if FEATURE_SETPRIV_CAPABILITIES or RUN_INIT 2018-02-21 20:13:39 +01:00
change_identity.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
chomp.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
common_bufsiz.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
compare_string_array.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
concat_path_file.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
concat_subpath_file.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
copy_file.c cp: optional --reflink support 2018-07-13 20:30:02 +02:00
copyfd.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
correct_password.c libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation 2018-04-07 15:08:12 +02:00
crc32.c libbb: commonalize a bit of little-endian CRC32 table generation code 2018-02-01 10:56:19 +01:00
default_error_retval.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
device_open.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
die_if_bad_username.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
dump.c hexdump: fix short file of zero butes treated as dup 2018-07-03 16:29:06 +02:00
endofname.c move endofname() to libbb 2013-02-26 00:36:53 +01:00
executable.c which: fix TODO with NOFORK+malloc_failure misbehaving 2018-01-12 13:21:33 +01:00
fclose_nonstdin.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
fflush_stdout_and_exit.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
fgets_str.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
find_mount_point.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
find_pid_by_name.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
find_root_device.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
full_write.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
get_console.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
get_cpu_count.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
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: new function bb_die_memory_exhausted 2018-04-01 19:59:37 +02:00
get_shell_name.c mark get_shell_name FAST_FUNC 2012-10-03 09:42:21 +02:00
get_volsize.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
getopt32.c hush: GETOPT_RESET() _after_ getopts too. 2017-08-29 14:32:17 +02:00
getopt_allopts.c getopt32: factor out code to treat all args as options 2017-08-04 16:33:23 +02:00
getpty.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
hash_md5_sha.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
hash_md5prime.c tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work 2017-01-24 16:00:54 +01:00
herror_msg.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
human_readable.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
in_ether.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
inet_cksum.c inet_cksum: big-endian fix 2011-09-08 10:59:26 +02:00
inet_common.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
inode_hash.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
isdirectory.c do not include <sys/stat.h> just before "libbb.h", it's there already 2017-10-05 14:41:36 +02:00
isqrt.c libbb: move isqrt from factor, use it in diff too 2017-04-11 07:34:56 +02:00
Kbuild.src libbb: compile obscure() only if FEATURE_PASSWD_WEAK_CHECK=y 2018-01-04 15:21:25 +01:00
kernel_version.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
last_char_is.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
lineedit_ptr_hack.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
lineedit.c hush: fix "unset PS1/PS2", and put them into initial variable set 2018-04-06 17:58:21 +02:00
llist.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
logenv.c zcip: Add environment variable for overriding log functionality 2014-11-04 12:19:04 +01:00
login.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
loop.c testsuite/mount.tests: fix false positive 2018-06-28 14:10:00 +02:00
make_directory.c fix compile failure in previous commit 2018-02-06 18:01:39 +01:00
makedev.c nicer looking ifdef in libbb/makedev.c 2011-01-24 23:53:12 +01:00
match_fstype.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
messages.c which: fix TODO with NOFORK+malloc_failure misbehaving 2018-01-12 13:21:33 +01:00
missing_syscalls.c make busybox more portable 2018-03-04 23:15:59 +01:00
mode_string.c do not include <sys/stat.h> just before "libbb.h", it's there already 2017-10-05 14:41:36 +02:00
mtab.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
nuke_str.c whitespace fixes 2018-07-17 15:04:17 +02:00
obscure.c unit-tests: implement the unit-testing framework 2014-06-22 16:30:41 +02:00
parse_config.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
parse_mode.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
percent_decode.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
perror_msg.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
perror_nomsg_and_die.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
perror_nomsg.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
pidfile.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
platform.c Bionic lacks ttyname_r; provide a workaround 2015-04-25 21:32:48 +02:00
print_flags.c whitespace and comment format fixes, no code changes 2017-10-05 15:33:28 +02:00
print_numbered_lines.c cat: fix "cat -An" ignoring -n; make numbering go througn all files 2017-07-14 10:47:18 +02:00
printable_string.c libbb: auto_string() for efficient handling of temporary malloced stirngs 2015-10-09 17:59:56 +02:00
printable.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
process_escape_sequence.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
procps.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
progress.c progress meter: add disabled code for a more stable ETA 2018-02-13 16:48:52 +01:00
ptr_to_globals.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
pw_encrypt_des.c do not use `a' quoting style in comments 2017-08-02 14:26:33 +02:00
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 tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work 2017-01-24 16:00:54 +01:00
pw_encrypt.c libbb: crypt() in newer glibc requires include <crypt.h> 2018-06-27 09:45:20 +02:00
read_key.c lineedit: fix handling of repeating Alt-b, Alt-f, Alt-d, Alt-Backspace 2016-11-24 15:04:00 +01:00
read_printf.c libbb: remove unnecessary argument to nonblock_immune_read 2015-04-20 13:41:32 +02:00
read.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
README *: trailing empty lines removed 2010-07-26 01:49:12 +02:00
recursive_action.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
remove_file.c xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copy 2018-04-07 15:23:10 +02:00
replace.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
rtc.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
run_shell.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
safe_gethostname.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
safe_poll.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
safe_strncpy.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
safe_write.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
securetty.c libbb: fix "error: redefinition of 'is_tty_secure'" 2017-04-13 17:55:05 +02:00
selinux_common.c whitespace cleanup. no code changes 2013-01-14 15:57:44 +01:00
setup_environment.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
signals.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
simplify_path.c whitespace cleanup 2010-10-29 11:46:52 +02:00
single_argv.c basename,dirname,freeramdisk,rx,raidautorun,runsv,chvt: skip "--" argument 2011-04-11 03:58:30 +02:00
skip_whitespace.c libbb: Use return value from is_prefixed_with() 2018-02-27 13:35:40 +01:00
speed_table.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
str_tolower.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
strrstr.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +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 whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
u_signal_names.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
ubi.c ubi tools: ubiupdatevol supports "-" input and actually respects -s SIZE 2017-08-07 16:00:25 +02:00
udp_io.c udp_io, traceroute: Standardise IPv6 PKTINFO handling to be portable 2017-10-30 16:06:50 +01:00
unicode.c lineedit: improve Unicode handling (still buggy though) 2013-08-19 16:44:05 +02:00
update_passwd.c fix breakage found by mass one-applet builds 2016-12-23 02:42:26 +01:00
utmp.c *: Switch to POSIX utmpx API 2015-04-02 23:03:46 +02:00
uuencode.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
verror_msg.c libbb: speed up error_msg functions 2016-04-03 16:55:03 +02:00
vfork_daemon_rexec.c make busybox more portable 2018-03-04 23:15:59 +01:00
warn_ignoring_args.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
wfopen_input.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
wfopen.c libbb: new function bb_die_memory_exhausted 2018-04-01 19:59:37 +02:00
write.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xatonum_template.c whitespace fixes. no code changes 2013-01-15 13:58:01 +01:00
xatonum.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xconnect.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xfunc_die.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xfuncs_printf.c hush: fix nested redirects colliding with script fds 2018-07-24 16:54:41 +02:00
xfuncs.c less: fix fallout from "use common routine to set raw termios" 2018-04-16 10:24:48 +02:00
xgetcwd.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xgethostbyname.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
xreadlink.c whitespace fix 2018-05-26 17:42:00 +02:00
xrealloc_vector.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
xregcomp.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00

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>