oweals/busybox.git
5 years agohush: restore redirected stdin
Denys Vlasenko [Fri, 1 Nov 2019 13:16:07 +0000 (14:16 +0100)]
hush: restore redirected stdin

function                                             old     new   delta
restore_redirects                                     52      95     +43
save_fd_on_redirect                                  243     253     +10
hfopen                                                90      99      +9
fgetc_interactive                                    259     261      +2
builtin_type                                         117     115      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 64/-2)              Total: 62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: decrease MIN_FREQHOLD by 2, increase "penalty" for largish offset x2
Denys Vlasenko [Wed, 30 Oct 2019 11:13:46 +0000 (12:13 +0100)]
ntpd: decrease MIN_FREQHOLD by 2, increase "penalty" for largish offset x2

> 2018-07-25:
> ntpd: increase MIN_FREQHOLD by 3
> This means we'll start correcting frequency ~5 minutes after start,
> not ~3.5 ones.
> With previous settings I still often see largish ~0.7s initial offsets
> only about 1/2 corrected before frequency correction kicks in,
> resulting in ~200ppm "correction" which is then slowly undone.

Review of real-world results of the above shows that with small
initial offsets, freq correction can be allowed to kick in sooner,
whereas with large (~0.8s) offsets, we still start freq correction
a bit too soon.

Let's rebalance this a bit.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonslookup: implement support for SRV records
Jo-Philipp Wich [Thu, 27 Jun 2019 15:27:29 +0000 (17:27 +0200)]
nslookup: implement support for SRV records

Add support for querying and parsing SRV DNS records.

function                                             old     new   delta
send_queries                                        1711    1865    +154
qtypes                                                72      80      +8

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonslookup: handle replies without RRs
Jo-Philipp Wich [Thu, 27 Jun 2019 15:27:28 +0000 (17:27 +0200)]
nslookup: handle replies without RRs

Under some circumstances, a DNS reply might contain no resource records,
e.g. when a valid domain is queried that does not have records of the
requested type.

Example with nslookup from BIND dnsutils:

    $ nslookup -q=SRV example.org
    Server: 10.11.12.13
    Address: 10.11.12.13#53

    Non-authoritative answer:
    *** Can't find example.org: No answer

Currently the busybox nslookup applet simply prints nothing after the
"Non-authoritative answer:" line in the same situation.

This change modifies nslookup to either print "Parse error" or "No answer"
diagnostics, depending on the parse_reply() return value.

function                                             old     new   delta
send_queries                                        1676    1711     +35

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogunzip: fix incorrect decoding of "fixed" inflate blocks
Denys Vlasenko [Sat, 26 Oct 2019 18:04:34 +0000 (20:04 +0200)]
gunzip: fix incorrect decoding of "fixed" inflate blocks

function                                             old     new   delta
huft_build                                          1008    1022     +14
inflate_block                                       1253    1256      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 17/0)               Total: 17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohdparm: placate "warning: taking the absolute value of unsigned type"
Denys Vlasenko [Fri, 25 Oct 2019 15:47:22 +0000 (17:47 +0200)]
hdparm: placate "warning: taking the absolute value of unsigned type"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: placate "warning: shifting a negative signed value is undefined"
Denys Vlasenko [Fri, 25 Oct 2019 15:42:23 +0000 (17:42 +0200)]
vi: placate "warning: shifting a negative signed value is undefined"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoread_key(): placate "warning: shifting a negative signed value is undefined"
Denys Vlasenko [Fri, 25 Oct 2019 15:40:57 +0000 (17:40 +0200)]
read_key(): placate "warning: shifting a negative signed value is undefined"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: abs(tmx.offset) was truncating a "long" typed value
Denys Vlasenko [Fri, 25 Oct 2019 15:35:58 +0000 (17:35 +0200)]
ntpd: abs(tmx.offset) was truncating a "long" typed value

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotc: array address is never NULL
Denys Vlasenko [Fri, 25 Oct 2019 11:41:31 +0000 (13:41 +0200)]
tc: array address is never NULL

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotraceroute: fix gcc-ism
Denys Vlasenko [Fri, 25 Oct 2019 11:39:41 +0000 (13:39 +0200)]
traceroute: fix gcc-ism

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosuppress a few "unused function" warnings
Denys Vlasenko [Fri, 25 Oct 2019 11:05:15 +0000 (13:05 +0200)]
suppress a few "unused function" warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonetstat: suppress a warning (conversion from 'int' to 'smallint' changes value)
Denys Vlasenko [Fri, 25 Oct 2019 11:00:01 +0000 (13:00 +0200)]
netstat: suppress a warning (conversion from 'int' to 'smallint' changes value)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoMakefile.flags: suppress some clang-9 warnings
Denys Vlasenko [Fri, 25 Oct 2019 10:56:51 +0000 (12:56 +0200)]
Makefile.flags: suppress some clang-9 warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoclang/llvm 9 fix - do not eliminate a store to a fake "const"
Denys Vlasenko [Fri, 25 Oct 2019 10:12:22 +0000 (12:12 +0200)]
clang/llvm 9 fix - do not eliminate a store to a fake "const"

This is *much* better (9 kbytes better) than dropping "*const"
optimization trick.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotar: fix fallout of: change -a from meaning "lzma" to mean "autodetect by extension"
Denys Vlasenko [Fri, 25 Oct 2019 08:30:53 +0000 (10:30 +0200)]
tar: fix fallout of: change -a from meaning "lzma" to mean "autodetect by extension"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoRemove syscall wrappers around clock_gettime, closes 12091
Denys Vlasenko [Thu, 24 Oct 2019 14:26:55 +0000 (16:26 +0200)]
Remove syscall wrappers around clock_gettime, closes 12091

12091 "Direct use of __NR_clock_gettime is not time64-safe".

function                                             old     new   delta
runsv_main                                          1698    1712     +14
startservice                                         378     383      +5
get_mono                                              31      25      -6
date_main                                            932     926      -6
gettimeofday_ns                                       17       -     -17
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29)            Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshell: better comments in BASE#nn code
Denys Vlasenko [Tue, 22 Oct 2019 12:25:43 +0000 (14:25 +0200)]
shell: better comments in BASE#nn code

function                                             old     new   delta
evaluate_string                                      932     930      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshell/ulimit: code shrink
Denys Vlasenko [Mon, 21 Oct 2019 14:47:09 +0000 (16:47 +0200)]
shell/ulimit: code shrink

    text    data     bss     dec     hex filename
1001949     551    5612 1008112   f61f0 busybox_old
1001906     551    5612 1008069   f61c5 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogunzip: code shrink by using int-, not short-sized struct member
Denys Vlasenko [Sun, 20 Oct 2019 17:07:06 +0000 (19:07 +0200)]
gunzip: code shrink by using int-, not short-sized struct member

function                                             old     new   delta
inflate_block                                       1254    1253      -1
inflate_codes                                        629     621      -8
huft_build                                          1054    1008     -46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-55)             Total: -55 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Sat, 19 Oct 2019 16:52:41 +0000 (18:52 +0200)]
gzip: code shrink

huft_build() still has way too many params

function                                             old     new   delta
lit                                                    -      94     +94
dist                                                   -      94     +94
huft_build                                          1058    1054      -4
inflate_block                                       1281    1254     -27
cpdext                                                30       -     -30
cplext                                                31       -     -31
cpdist                                                60       -     -60
cplens                                                62       -     -62
------------------------------------------------------------------------------
(add/remove: 2/4 grow/shrink: 0/2 up/down: 188/-214)          Total: -26 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Sat, 19 Oct 2019 16:33:49 +0000 (18:33 +0200)]
gzip: code shrink

huft_build() has way too many params

function                                             old     new   delta
inflate_block                                       1293    1281     -12
huft_build                                          1085    1058     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-39)             Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: add disabled code to emit EC and IP
Denys Vlasenko [Fri, 18 Oct 2019 14:47:37 +0000 (16:47 +0200)]
telnet: add disabled code to emit EC and IP

> I'm trying to connect to a Korenix 3005 switch through telnet
> for management purposes, and all is well except for the backspace character
> - seems like my switch doesn't handle it too well and instead of erasing
> the last character all it does is print some garbage to the screen.
> I've had the same issue before while using putty, but saw a solution that
> suggests to enable "Telnet special commands" in the options menu, and it
> worked.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: code shrink
Denys Vlasenko [Tue, 15 Oct 2019 10:31:54 +0000 (12:31 +0200)]
brctl: code shrink

function                                             old     new   delta
show_bridge                                          323     317      -6
brctl_main                                          2171    2164      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-13)             Total: -13 bytes
   text    data     bss     dec     hex filename
1002083     551    5612 1008246   f6276 busybox_old
1002065     551    5612 1008228   f6264 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoconfig: PID_FILE_PATH required for FEATURE_CROND_SPECIAL_TIMES
James Byrne [Wed, 17 Jul 2019 15:53:04 +0000 (15:53 +0000)]
config: PID_FILE_PATH required for FEATURE_CROND_SPECIAL_TIMES

When crond is built with FEATURE_CROND_SPECIAL_TIMES enabled, it creates
a file called 'crond.reboot' at CONFIG_PID_FILE_PATH, but if
FEATURE_PIDFILE is disabled, this will be an empty string and the file
will be created in the root directory, which is undesirable.

This commit makes PID_FILE_PATH depend on FEATURE_CROND_SPECIAL_TIMES as
well as FEATURE_PIDFILE so that you get sensible behaviour in crond when
FEATURE_PIDFILE is switched off.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: tweak help text, fix comments
Denys Vlasenko [Sat, 12 Oct 2019 17:51:46 +0000 (19:51 +0200)]
brctl: tweak help text, fix comments

function                                             old     new   delta
packed_usage                                       33255   33236     -19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: fold show_bridge_ports_ into its caller
Denys Vlasenko [Sat, 12 Oct 2019 17:42:37 +0000 (19:42 +0200)]
brctl: fold show_bridge_ports_ into its caller

function                                             old     new   delta
brctl_main                                          2235    2171     -64

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: code shrink
Denys Vlasenko [Sat, 12 Oct 2019 17:24:38 +0000 (19:24 +0200)]
brctl: code shrink

packed_usage                                       33253   33255      +2
write_uint                                            96      90      -6
show_bridge_timer                                     93      69     -24
brctl_main                                          2338    2235    -103
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-133)           Total: -131 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: add support for showstp command
Martin Lewis [Thu, 10 Oct 2019 21:00:19 +0000 (16:00 -0500)]
brctl: add support for showstp command

function                                             old     new   delta
brctl_main                                           974    2339   +1365
show_bridge_timer                                      -      93     +93
static.state_names                                     -      48     +48
printf_xstrtou                                         -      26     +26
packed_usage                                       33243   33253     +10
show_bridge                                          333     323     -10
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/1 up/down: 1542/-10)         Total: 1532 bytes
   text    data     bss     dec     hex filename
 999868     551    5612 1006031   f59cf busybox_old
1002309     551    5612 1008472   f6358 busybox_unstripped

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodpkg-deb: work around bogus error message when working with XZ compressed packages
Denys Vlasenko [Fri, 11 Oct 2019 12:11:44 +0000 (14:11 +0200)]
dpkg-deb: work around bogus error message when working with XZ compressed packages

function                                             old     new   delta
unpack_xz_stream                                    2309    2317      +8
bb_full_fd_action                                    464     472      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoreplace: count_strstr - Handle an edge case where sub is empty
Martin Lewis [Sun, 15 Sep 2019 16:51:30 +0000 (18:51 +0200)]
replace: count_strstr - Handle an edge case where sub is empty

If sub is empty, avoids an infinite loop.

function                                             old     new   delta
count_strstr                                          45      63     +18

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: Converted safe_read to safe_write format
Martin Lewis [Sun, 15 Sep 2019 16:13:28 +0000 (18:13 +0200)]
libbb: Converted safe_read to safe_write format

Changed safe_read to be symmetrical to safe_write, it shall
never return EINTR because it calls read multiple times,
the error is considered transient.

function                                             old     new   delta
safe_read                                             44      57     +13

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agorunsv: Use 64 prefix syscall if we have to
Alistair Francis [Wed, 18 Sep 2019 16:28:51 +0000 (09:28 -0700)]
runsv: Use 64 prefix syscall if we have to

Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.

This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.

If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t report a compilation error. This avoids us have to
deal with converting between 64-bit and 32-bit values. There are
currently no architectures where this is the case.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotime: Use 64 prefix syscall if we have to
Alistair Francis [Wed, 18 Sep 2019 16:28:50 +0000 (09:28 -0700)]
time: Use 64 prefix syscall if we have to

Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.

This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.

If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t report a compilation error. This avoids us have to
deal with converting between 64-bit and 32-bit values. There are
currently no architectures where this is the case.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodate: Use 64 prefix syscall if we have to
Alistair Francis [Wed, 18 Sep 2019 16:28:49 +0000 (09:28 -0700)]
date: Use 64 prefix syscall if we have to

Some 32-bit architectures no longer have the 32-bit time_t syscalls.
Instead they have suffixed syscalls that returns a 64-bit time_t. If
the architecture doesn't have the non-suffixed syscall and is using a
64-bit time_t let's use the suffixed syscall instead.

This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
headers.

If an architecture only supports the suffixed syscalls, but is still
using a 32-bit time_t fall back to the libc call.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: fix segmentation fault on empty bin opt
Michal Kazior [Wed, 25 Sep 2019 12:03:13 +0000 (14:03 +0200)]
udhcpc: fix segmentation fault on empty bin opt

The following caused udhcpc to segfault:
  busybox udhcpc -i lo -s /dev/null -x 0x3d:

function                                             old     new   delta
udhcp_str2optset                                     629     641     +12

Signed-off-by: Michal Kazior <michal@plume.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: add support for showmacs command
Martin Lewis [Sun, 15 Sep 2019 16:04:49 +0000 (18:04 +0200)]
brctl: add support for showmacs command

function                                             old     new   delta
brctl_main                                           680     974    +294
packed_usage                                       33167   33187     +20
compare_fdbs                                           -      19     +19
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 333/0)             Total: 333 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoln: --no-target-directory implies --no-dereference
Kaarle Ritvanen [Tue, 8 Oct 2019 12:07:50 +0000 (14:07 +0200)]
ln: --no-target-directory implies --no-dereference

as in GNU coreutils

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoroute: fix output of "route -n -A inet6"
Tomas Paukrt [Tue, 8 Oct 2019 09:51:48 +0000 (11:51 +0200)]
route: fix output of "route -n -A inet6"

The output of the command "route -n -A inet6" may be corrupted
due to partially initialized structure snaddr6 in the function
INET6_displayroutes.

Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotee: do not intercept SIGPIPE
Denys Vlasenko [Mon, 7 Oct 2019 12:25:45 +0000 (14:25 +0200)]
tee: do not intercept SIGPIPE

GNU tee does this only with -p, which we don't have yet.

function                                             old     new   delta
tee_main                                             306     295     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofdisk_aix: fix aliasing warning, comment out unused global variables
Denys Vlasenko [Fri, 4 Oct 2019 15:16:15 +0000 (17:16 +0200)]
fdisk_aix: fix aliasing warning, comment out unused global variables

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofdisk: avoid overflow in "mega/gigabytes" calculation, code shrink
Denys Vlasenko [Fri, 4 Oct 2019 14:45:04 +0000 (16:45 +0200)]
fdisk: avoid overflow in "mega/gigabytes" calculation, code shrink

function                                             old     new   delta
list_disk_geometry                                   175     145     -30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnet: fix uninitialized variable bug
Denys Vlasenko [Wed, 25 Sep 2019 11:48:01 +0000 (13:48 +0200)]
telnet: fix uninitialized variable bug

function                                             old     new   delta
telnet_main                                         1236    1238      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: add ELAPSED_TIME option to outgoing packets
Denys Vlasenko [Tue, 24 Sep 2019 12:01:00 +0000 (14:01 +0200)]
udhcpc6: add ELAPSED_TIME option to outgoing packets

function                                             old     new   delta
init_d6_packet                                        53     121     +68
udhcpc_main                                         2577    2582      +5
udhcpc6_main                                        2593    2597      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 77/0)               Total: 77 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: fix BASE###nn bashism for bases 36..64
Denys Vlasenko [Sun, 22 Sep 2019 21:40:10 +0000 (23:40 +0200)]
ash: fix BASE###nn bashism for bases 36..64

function                                             old     new   delta
evaluate_string                                      876     932     +56

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: fix BASE###nn bashism to accept letter 'digits' for bases > 9
Denys Vlasenko [Sun, 22 Sep 2019 16:26:05 +0000 (18:26 +0200)]
ash: fix BASE###nn bashism to accept letter 'digits' for bases > 9

function                                             old     new   delta
evaluate_string                                      873     876      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: Add 'U' suffix in UINT_MAX preprocessor check
Kang-Che Sung [Thu, 5 Sep 2019 15:40:38 +0000 (23:40 +0800)]
bc: Add 'U' suffix in UINT_MAX preprocessor check

Without the 'U' unsigned suffix, gcc will throw a "integer constant is
so large that it is unsigned" warning.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agowget: increase redirections limit
David Demelier [Thu, 29 Aug 2019 12:05:27 +0000 (14:05 +0200)]
wget: increase redirections limit

Some hosting services like sourceforge perform a lot of relocations
before actually serving the file. Example of current limitation:

    busybox wget http://sourceforge.net/projects/fluxbox/files/fluxbox/1.3.7/fluxbox-1.3.7.tar.xz
    Connecting to sourceforge.net (216.105.38.13:80)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to downloads.sourceforge.net (216.105.38.13:443)
    wget: too many redirections

Signed-off-by: David Demelier <markand@malikania.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexamples/udhcp/simple.script: print the filename actually changed
Rolf Eike Beer [Tue, 13 Aug 2019 15:41:56 +0000 (17:41 +0200)]
examples/udhcp/simple.script: print the filename actually changed

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofind: implement -empty
Aaro Koskinen [Thu, 12 Sep 2019 10:04:13 +0000 (12:04 +0200)]
find: implement -empty

function                                             old     new   delta
func_empty                                             -     121    +121
packed_usage                                       33154   33167     +13
parse_params                                        1490    1500     +10
static.params                                        228     235      +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 151/0)             Total: 151 bytes

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Fri, 6 Sep 2019 15:56:57 +0000 (17:56 +0200)]
gzip: code shrink

Converted a few 16-bit variables and small arrays to 32-bit.

Stopped pulling desc->FOO members into temporary local variables
in gen_bitlen(): on register-starved arches, this is a loss,
temporaries go into stack slots.

Sprinkled a few "const" on pointer arguments.

function                                             old     new   delta
pack_gzip                                            742     745      +3
gen_codes                                            101      97      -4
build_tree                                           886     833     -53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-57)             Total: -54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexamples/udhcp/simple.script: up interface on deconfig event
Denys Vlasenko [Thu, 5 Sep 2019 12:58:08 +0000 (14:58 +0200)]
examples/udhcp/simple.script: up interface on deconfig event

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: add a FIXME comment
Denys Vlasenko [Thu, 5 Sep 2019 12:31:49 +0000 (14:31 +0200)]
ash: add a FIXME comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: fix "set -o INVALID" affecting -e flag state
Denys Vlasenko [Thu, 5 Sep 2019 12:07:14 +0000 (14:07 +0200)]
hush: fix "set -o INVALID" affecting -e flag state

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Thu, 5 Sep 2019 11:22:24 +0000 (13:22 +0200)]
gzip: code shrink

function                                             old     new   delta
gzip_main                                            267     264      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: set default compression level to 6 when CONFIG_FEATURE_GZIP_LEVELS=n
Daniel Edgecumbe [Mon, 2 Sep 2019 21:09:15 +0000 (22:09 +0100)]
gzip: set default compression level to 6 when CONFIG_FEATURE_GZIP_LEVELS=n

With this change, GNU gzip -n and BusyBox gzip now produce identical output
assuming that CONFIG_GZIP_FAST=2.

>> Excuse me, but I wonder one thing: Why should we follow
>> strictly with gzip on the no-options default behavior?

> First, the default 6 compression level is a de-facto standard. BSD gzip
> and Apple gzip (on macOS) use this default as well. So there is a
> reasonable expectation that different gzip implementations act the same.
> For instance, if the default for busybox gzip becomes 9, then someone
> writing a script using busybox gzip could reasonably expect that the
> compression level will still be 9 when the same script is run on another
> system. That would be wrong. Implementations should not deviate from
> de-facto standards without a strong reason.
>
> Second, the inherent reason for this default has not gone away. While
> processor speeds have exploded since the default was set, so has the
> typical size of compressed files. Multiple gigabytes are nothing unusual
> these days. And gzip is often used for compression on the fly, precisely
> because it offers a good compromise between speed and compression ratio.
> So I believe 6 continues to be a reasonable default.

function                                             old     new   delta
deflate                                              939     927     -12

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: set compression flags correctly as per standard
Daniel Edgecumbe [Mon, 2 Sep 2019 21:05:26 +0000 (22:05 +0100)]
gzip: set compression flags correctly as per standard

With this change and CONFIG_GZIP_FAST=2, CONFIG_FEATURE_GZIP_LEVELS=y,

GNU gzip and BusyBox gzip now produce identical output at each compression
level (excluding 1..3, as BusyBox does not implement these levels).

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: default level with ENABLE_FEATURE_GZIP_LEVELS should be 6
Daniel Edgecumbe [Mon, 2 Sep 2019 21:03:14 +0000 (22:03 +0100)]
gzip: default level with ENABLE_FEATURE_GZIP_LEVELS should be 6

Fixes an off-by-one that actually resulted in level 7 being used

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: Parse error & fix out of bounds read in xc_program_printString
Brian Foley [Thu, 5 Sep 2019 08:53:21 +0000 (10:53 +0200)]
dc: Parse error & fix out of bounds read in xc_program_printString

function                                             old     new   delta
xc_program_print                                     712     735     +23

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: Fix segfault when executing strings generated using asciify
Brian Foley [Thu, 5 Sep 2019 08:50:13 +0000 (10:50 +0200)]
dc: Fix segfault when executing strings generated using asciify

function                                             old     new   delta
zxc_vm_process                                      6884    6891      +7

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: execute shouldn't pop if stack head is not a string
Brian Foley [Thu, 5 Sep 2019 08:46:22 +0000 (10:46 +0200)]
dc: execute shouldn't pop if stack head is not a string

This matches the behaviour of both GNU dc (as specified in
its man page), and BSD dc (where stack_popstring() pops
only if the head is a string.)

Add a couple of tests to verify this behavior.

function                                             old     new   delta
zxc_vm_process                                      6882    6884      +2

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: support stateless DHCPv6
Eivind Versvik [Sat, 24 Aug 2019 15:23:48 +0000 (17:23 +0200)]
udhcpc6: support stateless DHCPv6

-l will send Information-Request to request configuration parameters

function                                             old     new   delta
packed_usage                                       33114   33180     +66
send_d6_info_request                                   -      62     +62
udhcpc6_main                                        2534    2593     +59
udhcpc6_longopts                                     199     211     +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 199/0)             Total: 199 bytes

Signed-off-by: Eivind Versvik <versvikeivind@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotop: do not use previous colleced data wheh "h" toggles threads display
Denys Vlasenko [Sun, 11 Aug 2019 14:17:11 +0000 (16:17 +0200)]
top: do not use previous colleced data wheh "h" toggles threads display

This prevents first update from showing incorrect CPU usage data

function                                             old     new   delta
handle_input                                         620     643     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: s/iphdr/ip6_hdr/
Denys Vlasenko [Fri, 9 Aug 2019 18:43:40 +0000 (20:43 +0200)]
udhcpc6: s/iphdr/ip6_hdr/

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonmeter: do not clamp down %Nc to minimum of 10 (think nmeter "%`nproc`c")
Denys Vlasenko [Tue, 6 Aug 2019 14:56:00 +0000 (16:56 +0200)]
nmeter: do not clamp down %Nc to minimum of 10 (think nmeter "%`nproc`c")

Also, go for unsigned divisions.

function                                             old     new   delta
init_cpu                                              61      73     +12
collect_cpu                                          444     422     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-22)            Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostat: print nanosecond times, fix printing of empty lines
Denys Vlasenko [Sat, 3 Aug 2019 16:08:27 +0000 (18:08 +0200)]
stat: print nanosecond times, fix printing of empty lines

function                                             old     new   delta
human_time                                            36      73     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: fix set -o to not show "nameless" options
Denys Vlasenko [Fri, 2 Aug 2019 14:43:36 +0000 (16:43 +0200)]
ash: fix set -o to not show "nameless" options

Patch by Martijn Dekker <martijn@inlv.org>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotar: change -a from meaning "lzma" to mean "autodetect by extension"
Denys Vlasenko [Fri, 2 Aug 2019 13:19:56 +0000 (15:19 +0200)]
tar: change -a from meaning "lzma" to mean "autodetect by extension"

function                                             old     new   delta
tar_main                                            1026    1100     +74
packed_usage                                       33311   33329     +18
tar_longopts                                         309     325     +16
vfork_compressor                                     246     210     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 108/-36)            Total: 72 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotar: code shrink
Denys Vlasenko [Thu, 1 Aug 2019 13:07:21 +0000 (15:07 +0200)]
tar: code shrink

function                                             old     new   delta
writeLongname                                        226     228      +2
static.prefilled                                      48       -     -48
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 2/-48)             Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: only catch unexpected exceptions in PS1 expansion
Ron Yorston [Mon, 29 Jul 2019 08:51:14 +0000 (09:51 +0100)]
ash: only catch unexpected exceptions in PS1 expansion

Commit d1a2fa2a4 (ash: catch error in arithmetic expansion in PS1)
catches all exceptions raised by expandarg().  Some exceptions, such as
the EXEXIT raised when command expansion is used, are expected:

   export PS1='$(echo "$ ")'

These should be processed normally or the shell hangs at the prompt.

function                                             old     new   delta
expandstr                                            344     353      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agounicode: code shrink in character width determination
Denys Vlasenko [Tue, 23 Jul 2019 09:26:54 +0000 (11:26 +0200)]
unicode: code shrink in character width determination

function                                             old     new   delta
bb_wcwidth                                           267     238     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: include <crypt.h> only if necessary
Denys Vlasenko [Tue, 16 Jul 2019 13:09:06 +0000 (15:09 +0200)]
libbb: include <crypt.h> only if necessary

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: add comment about mode6, no code changes
Denys Vlasenko [Tue, 2 Jul 2019 13:03:47 +0000 (15:03 +0200)]
ntpd: add comment about mode6, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: commonalize message strings
Denys Vlasenko [Tue, 2 Jul 2019 11:10:19 +0000 (13:10 +0200)]
ntpd: commonalize message strings

function                                             old     new   delta
recv_and_process_peer_pkt                            961     973     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 12/0)               Total: 12 bytes
   text    data     bss     dec     hex filename
 953108     481    7288  960877   ea96d busybox_old
 953086     481    7288  960855   ea957 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: reduce the overhead of single parameter bb_error_msg() calls
James Byrne [Tue, 2 Jul 2019 09:35:03 +0000 (11:35 +0200)]
libbb: reduce the overhead of single parameter bb_error_msg() calls

Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: abort if argvs are (unexpectedly) given
Denys Vlasenko [Tue, 2 Jul 2019 09:28:18 +0000 (11:28 +0200)]
ntpd: abort if argvs are (unexpectedly) given

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofree: include SReclaimable in cached value
Lukas Rusak [Tue, 25 Jun 2019 16:52:33 +0000 (18:52 +0200)]
free: include SReclaimable in cached value

I noticed that the 'used' values from busybox free and
procps-ng free differed so I looked into why. It turns
out that procps-ng uses the "SReclaimable" value as
part of the cached value.

This was changed in
procps-ng commit 05d751c4f076a2f0118b914c5e51cfbb4762ad8e

function                                             old     new   delta
free_main                                            633     653     +20

Signed-off-by: Lukas Rusak <lorusak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: deal with "declaration of 'link' shadows a global declaration" warning
Denys Vlasenko [Tue, 25 Jun 2019 16:51:00 +0000 (18:51 +0200)]
libbb: deal with "declaration of 'link' shadows a global declaration" warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agopidof: support "pidof /path/to/binary" case
Denys Vlasenko [Sat, 15 Jun 2019 16:35:39 +0000 (18:35 +0200)]
pidof: support "pidof /path/to/binary" case

function                                             old     new   delta
find_pid_by_name                                     230     227      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoreadlink,realpath: fix a case with a symplink, closes 11021
Denys Vlasenko [Thu, 13 Jun 2019 15:08:29 +0000 (17:08 +0200)]
readlink,realpath: fix a case with a symplink, closes 11021

function                                             old     new   delta
xmalloc_realpath_coreutils                           125     201     +76

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: fix comment, no code changes
Denys Vlasenko [Thu, 13 Jun 2019 08:02:03 +0000 (10:02 +0200)]
udhcpc: fix comment, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: fix aliasing warning
Denys Vlasenko [Tue, 11 Jun 2019 16:18:48 +0000 (18:18 +0200)]
udhcpc6: fix aliasing warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcpc.c: Added support for relay server parameter.
Martin Lewis [Mon, 10 Jun 2019 15:06:17 +0000 (17:06 +0200)]
dhcpc.c: Added support for relay server parameter.

Resolved a TODO by adding support for gateway_nip parameter.

function                                             old     new   delta
udhcp_run_script                                     792     835     +43

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoStart 1.32.0 development cycle
Denys Vlasenko [Mon, 10 Jun 2019 10:52:16 +0000 (12:52 +0200)]
Start 1.32.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoBump version to 1.31.0 1_31_0
Denys Vlasenko [Mon, 10 Jun 2019 09:53:46 +0000 (11:53 +0200)]
Bump version to 1.31.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agomount,losetup: use /dev/loop-control is it exists
Denys Vlasenko [Sun, 9 Jun 2019 21:20:49 +0000 (23:20 +0200)]
mount,losetup: use /dev/loop-control is it exists

function                                             old     new   delta
get_free_loop                                          -      58     +58
set_loop                                             597     649     +52
losetup_main                                         482     476      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6)            Total: 104 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: change priority before dropping privileges
Aitor Esteve Alvarado [Thu, 7 Mar 2019 09:14:48 +0000 (10:14 +0100)]
start-stop-daemon: change priority before dropping privileges

Currently start-stop-daemon fails when using both the -c option (set uid)
and -N option (set niceness/priority) as it first drops privileges and then
tries to increase the priority. This patch changes the order of execution.

Signed-off-by: Aitor Esteve Alvarado <aesteve@singularaircraft.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftp: allow -lc and -cl options
Denys Vlasenko [Sun, 9 Jun 2019 10:41:17 +0000 (12:41 +0200)]
tftp: allow -lc and -cl options

function                                             old     new   delta
tftp_main                                            394     396      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftpd: revert erroneous change
Denys Vlasenko [Sun, 9 Jun 2019 09:32:23 +0000 (11:32 +0200)]
tftpd: revert erroneous change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftp: optional tftp-hpa compat
Denys Vlasenko [Sun, 9 Jun 2019 09:12:02 +0000 (11:12 +0200)]
tftp: optional tftp-hpa compat

function                                             old     new   delta
tftp_main                                            276     394    +118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexpand: add commented-out code to handle NULs
Denys Vlasenko [Sun, 9 Jun 2019 07:16:03 +0000 (09:16 +0200)]
expand: add commented-out code to handle NULs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexpand,unexpand: drop broken test, add FIXME comment
Denys Vlasenko [Sat, 8 Jun 2019 11:04:44 +0000 (13:04 +0200)]
expand,unexpand: drop broken test, add FIXME comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoawk: fix testsuite
Denys Vlasenko [Sat, 8 Jun 2019 11:00:46 +0000 (13:00 +0200)]
awk: fix testsuite

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:58:16 +0000 (12:58 +0200)]
bc: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Sat, 8 Jun 2019 10:57:07 +0000 (12:57 +0200)]
vi: code shrink

function                                             old     new   delta
colon                                               2852    2846      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:39:30 +0000 (12:39 +0200)]
bc: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:35:06 +0000 (12:35 +0200)]
brctl: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoblockdev: add usage comment, no code changes
Denys Vlasenko [Sat, 8 Jun 2019 06:57:11 +0000 (08:57 +0200)]
blockdev: add usage comment, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: .js is "application/javascript", not "application/x-javascript"
Denys Vlasenko [Fri, 7 Jun 2019 10:32:30 +0000 (12:32 +0200)]
httpd: .js is "application/javascript", not "application/x-javascript"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agopasswd: do not set 0 as date of last password change, closes 11951
Denys Vlasenko [Fri, 7 Jun 2019 10:29:24 +0000 (12:29 +0200)]
passwd: do not set 0 as date of last password change, closes 11951

function                                             old     new   delta
update_passwd                                       1491    1505     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>