Commit Graph

17710 Commits (61a4959251667751e424e600c6cb75de39d6b1c3)

Author SHA1 Message Date
Ron Yorston 470fa7b364 ash: make EPOCH variables work if RANDOM is disabled
Commit 1d37186fe2 (ash: add bash-compatible EPOCH variables) added
support for the EPOCHSECONDS and EPOCHREALTIME variables.

These variables are dynamic and therefore require the VDYNAMIC flag
to be non-zero.  However, this is only the case if support for the
RANDOM variable is enabled.

Give VDYNAMIC a non-zero value if either EPOCH variables or RANDOM
are enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-29 16:45:13 +02:00
Ron Yorston f2e659415a lineedit: fix matching of directories when searching PATH
Commit 8baa643a3 (lineedit: match local directories when searching
PATH) included subdirectories of the current directory in the search
when tab-completing commands.

Unfortunately a short time later commit 1d180cd74 (lineedit: use
strncmp instead of is_prefixed_with (we know the length)) broke
this feature by returning an incorrect length for the array of paths.

Fix the length and reinstate matching of subdirectories.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-29 16:45:13 +02:00
Denys Vlasenko a59e5a7d08 libbb/sha: do not read shaNI variable twice, and factor out its setting
My gcc inlines both calls, so instead of "-20 bytes" I get only this:

function                                             old     new   delta
sha256_begin                                          84      83      -1
sha1_begin                                           114     111      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-4)               Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-29 15:46:32 +02:00
Denys Vlasenko bd76b75f72 libbb/sha: fix sha-NI instruction detection
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-29 15:17:00 +02:00
Denys Vlasenko 3253d7fe00 httpd: do not mangle cgi-bin/SCRIPT/params URLs
If cgi-bin/ prefix is seen, do not test the rest for existence,
whether it's a dir, and such.

function                                             old     new   delta
handle_incoming_and_exit                            2200    2212     +12

Reported here:
https://lists.zx2c4.com/pipermail/cgit/2023-March/004825.html

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-28 18:56:08 +02:00
David Leonard d8a3360380 find: implement -ok
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html

  -ok  utility_name  [argument ...] ;
    The -ok primary shall be equivalent to -exec, except that the use
    of a <plus-sign> to punctuate the end of the primary expression
    need not be supported, and find shall request affirmation of the
    invocation of utility_name using the current file as an argument
    by writing to standard error as described in the STDERR section. If
    the response on standard input is affirmative, the utility shall be
    invoked. Otherwise, the command shall not be invoked and the value
    of the -ok operand shall be false.

function                                             old     new   delta
do_exec                                              438     517     +79
parse_params                                        1833    1845     +12
static.params                                        288     292      +4
.rodata                                           100771  100775      +4
packed_usage                                       34543   34541      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 99/-2)              Total: 97 bytes

Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-28 18:08:02 +02:00
Arsen Arsenović 2d4a3d9e6c fixdep: avoid underflow when end of entry doesn't coincide with EOF
Bug: https://bugs.gentoo.org/893776
Closes: https://bugs.busybox.net/show_bug.cgi?id=15326
Signed-off-by: Arsen Arsenović <arsen@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-02-27 13:09:44 +01:00
Denys Vlasenko 029740a3e4 unzip: document some options we might support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-02-23 12:00:36 +01:00
Denys Vlasenko 75197998c2 unzip: clear SUID/GID bits, implement -K to not clear them
function                                             old     new   delta
unzip_main                                          2656    2715     +59
packed_usage                                       34517   34552     +35
.rodata                                           105250  105251      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 95/0)               Total: 95 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-02-22 10:50:14 +01:00
Denys Vlasenko 669c40ed8e top: stop using div() from libc, compilers now do it better
function                                             old     new   delta
div                                                   23       -     -23
display_process_list                                1237    1178     -59
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-82)             Total: -82 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-02-13 15:05:19 +01:00
Denys Vlasenko 93ae7464e6 hush: restore SIGHUP handling, this time explain why we do what we do
function                                             old     new   delta
check_and_run_traps                                  229     278     +49

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-30 18:48:36 +01:00
Denys Vlasenko 1fdb33bd07 hush: restore tty pgrp on SIGHUP
Found one case where SIGHUP does need some handling.

ash does not restore tty pgrp when killed by SIGHUP, and
this means process which started ash needs to restore it,
or it would get backgrounded when trying to use tty.

function                                             old     new   delta
check_and_run_traps                                  214     229     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-30 16:49:48 +01:00
Denys Vlasenko 6101b6d3ea hush: remove special handling of SIGHUP
Kernel should do the right thing.
(ash and dash do not have special SIGHUP handling.)

function                                             old     new   delta
check_and_run_traps                                  278     214     -64

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-30 15:57:04 +01:00
Denys Vlasenko 93e0898c66 shell: fix SIGWINCH and SIGCHLD (in hush) interrupting line input, closes 15256
function                                             old     new   delta
record_pending_signo                                  32      63     +31
lineedit_read_key                                    231     224      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-7)              Total: 24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-26 12:56:33 +01:00
Denys Vlasenko c2739e11de nmeter: increase maximum /proc file size (needed for large machines)
function                                             old     new   delta
get_file                                             185     201     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-24 12:47:32 +01:00
Denys Vlasenko 1040f78176 ntpd: correct comment: 2^-20 is ~1 microsecond (confused with 10^-20)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-18 18:04:22 +01:00
Denys Vlasenko 479bd7af0d ntpd: fold d_to_tv() into its only caller
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-18 17:42:17 +01:00
Denys Vlasenko c344ca6c7f ntpd: correct fixed->float conversions of fractions
Need to divide by (1<<32), not by (1<<32)-1.
Fraction of 0xffffffff is not 1 whole second.

function                                             old     new   delta
.rodata                                           105264  105268      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-17 17:01:05 +01:00
Miroslav Lichvar 85acf71d25 ntpd: make NTP client and server Y2036/2038-ready
The 32-bit integer part of the NTP timestamp overflows in year 2036,
which starts the second NTP era.

Modify the timestamp conversion to shift values between 1900-1970 (in
the first era) to the second era to enable the client to measure its
offset correctly until year 2106 (assuming 64-bit time_t).

Also update the conversion from double used when stepping the clock to
work with 64-bit time_t after reaching the maximum 32-bit value in 2038
and the server conversion to work correctly in the next NTP era.

function                                             old     new   delta
lfp_to_d                                              51      64     +13
step_time                                            326     332      +6
.rodata                                           105260  105264      +4
d_to_lfp                                             100      86     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 23/-14)              Total: 9 bytes

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-17 16:48:54 +01:00
Sören Tempel ca96022d6e ed: don't use memcpy with overlapping memory regions
The memcpy invocations in the subCommand function, modified by this
commit, previously used memcpy with overlapping memory regions. This is
undefined behavior. On Alpine Linux, it causes BusyBox ed to crash since
we compile BusyBox with -D_FORTIFY_SOURCE=2 and our fortify-headers
implementation catches this source of undefined behavior [0]. The issue
can only be triggered if the replacement string is the same size or
shorter than the old string.

Looking at the code, it seems to me that a memmove(3) is what was
actually intended here, this commit modifies the code accordingly.

[0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13504

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-05 16:21:48 +01:00
Denys Vlasenko b1884deb51 Start 1.37.0 development cycle
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 15:32:00 +01:00
Denys Vlasenko 70f77e4617 Bump version to 1.36.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 15:15:41 +01:00
Denys Vlasenko 969e008168 hush: code shrink
function                                             old     new   delta
run_list                                            1032    1012     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 14:08:18 +01:00
Denys Vlasenko d488a5218b ash: trivial code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 13:39:14 +01:00
Denys Vlasenko bcb90b9c41 xxd: use bb_simple_perror_msg... where appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 08:30:12 +01:00
Denys Vlasenko 27be0e8cfe shell: fix compile failures in some configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 08:28:16 +01:00
Denys Vlasenko 8ed57db65b Makefile.flags: add resolv to LDLIBS for linux compilers too (not only gnu ones)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:10:04 +01:00
Denys Vlasenko 9b2d766e0e sed: fix double-free in FEATURE_CLEAN_UP=y configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:05:55 +01:00
Denys Vlasenko cadf57b3af mv: fix error in !VERBOSE configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:04:44 +01:00
Denys Vlasenko e7977df2ca libbb/loop: fix compile failure (name collision)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:03:44 +01:00
Denys Vlasenko fb0c000567 testsuite/sha1sum.tests: fix false positive failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:02:17 +01:00
Denys Vlasenko dc068abad5 testsuite/tree.tests: fix false positive failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 17:01:14 +01:00
Denys Vlasenko adb1c7dcfe xxd: fix use of non-initialized data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-02 16:59:40 +01:00
Denys Vlasenko c4d296aa7c xargs: implement -o, closes 15146
function                                             old     new   delta
.rodata                                           105225  105259     +34
d6_listen_socket                                     150     180     +30
packed_usage                                       34512   34532     +20
d6_read_interface                                    595     581     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 84/-14)             Total: 70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-22 10:38:08 +01:00
Denys Vlasenko 02ca565646 udhcpc6: fix binding to network aliases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-15 23:57:27 +01:00
Denys Vlasenko 6c2ddf808e udhcp: add a few comments, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-15 13:34:52 +01:00
Denys Vlasenko 242d056230 udhcpc6: use a different default config script
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-15 11:51:16 +01:00
Denys Vlasenko 301ef96892 udhcpc6: align FF02__1_2[]
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-15 11:49:00 +01:00
Natanael Copa 3636d52cbe more: accept and ignore -e
Accept and ignore -e which is specified in POSIX.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-14 16:05:43 +01:00
Denys Vlasenko e977853e70 udhcpc6: add some comments
RFCs for DHCPv6 are written rather badly...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-14 00:36:59 +01:00
Denys Vlasenko 9898db4c94 udhcpc6: remove stray comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 23:21:59 +01:00
Denys Vlasenko 7710250e4a libbb: shrink del_loop()
function                                             old     new   delta
del_loop                                              52      49      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 16:00:00 +01:00
Denys Vlasenko a55bd1c484 loop: restore the correct return vaule of set_loop()
It is only used by mount's error path, though...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 15:52:52 +01:00
Denys Vlasenko 45734a2351 loop: optionally use ioctl(LOOP_CONFIGURE) to set up loopdevs
LOOP_CONFIGURE is added to Linux 5.8

function                                             old     new   delta
NO_LOOP_CONFIGURE (old code):
set_loop                                             784     782      -2
LOOP_CONFIGURE:
set_loop                                             784     653    -131
TRY_LOOP_CONFIGURE:
set_loop                                             784     811     +27

Based on a patch by Xiaoming Ni <nixiaoming@huawei.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 15:21:28 +01:00
Denys Vlasenko 9df54deead testsuite/mount.tests: accomodate umount failure seen on 5.18.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 15:12:31 +01:00
Xiaoming Ni a1856934ba loop: refactor: extract subfunction set_loopdev_params()
Extract subfunction set_loop_info() from set_loop()

function                                             old     new   delta
set_loop                                             760     784     +24

Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-13 14:26:20 +01:00
Xiaoming Ni 7dc76c9f21 loop: simplify code of LOOP_SET_FD failure
function                                             old     new   delta
set_loop                                             790     760     -30

Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-12 19:03:06 +01:00
Xiaoming Ni ddccf6cd2f loop: refactor: extract subfunction get_next_free_loop()
Extract subfunction get_next_free_loop() from set_loop()

Also fix miss free(try) when stat(try) and mknod fail

function                                             old     new   delta
set_loop                                             807     790     -17

Fixes: 3448914e8cc5 ("mount,losetup: use /dev/loop-control is it exists")
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-12 18:57:09 +01:00
Brandon Maier 90456a6aa3 xxd: fix typo in trivial usage
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-12-08 17:13:11 +01:00
Peter Kaestle 7ade421b1a unzip -l: add missed big-endian conversions date and time
When calling unzip -l the date and time output was missing big-endian
conversions.

Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-11-29 14:44:39 +01:00