Commit Graph

2968 Commits

Author SHA1 Message Date
Martin Lewis
d30d1ebc11 dhcpc: refactor xmalloc_optname_optval to shrink binary size
function                                             old     new   delta
len_of_option_as_string                               14      13      -1
dhcp_option_lengths                                   14      13      -1
udhcp_str2optset                                     641     637      -4
static.xmalloc_optname_optval                        777     718     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-65)             Total: -65 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:59:56 +02:00
Ron Yorston
17764603f2 httpd: allow '-h' to work when daemonized with NOMMU enabled
Commit d1b75e184 (httpd: permit non-default home directory with NOMMU
enabled) only works when used with the '-f' (foreground) option.

When '-f' isn't specified and NOMMU is enabled bb_daemonize_or_rexec()
is called to daemonize the server.  Since the server process has been
re-execed the previous patch results in the xchdir() not being called.

Fix this by resetting the re_execed variable in this case.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:38:21 +02:00
Denys Vlasenko
0cad5f9b6d udhcp: comment out unused domain compression code
function                                             old     new   delta
attach_option                                        411     406      -5
dname_enc                                            381     167    -214
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-219)           Total: -219 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 17:22:06 +02:00
Martin Lewis
726d0d148b dhcpc: code shrink in good_hostname
Incorporated valid_domain_label into good_hostname to simplify the implementation.

function                                             old     new   delta
static.xmalloc_optname_optval                        973     958     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15)             Total: -15 bytes
   text	   data	    bss	    dec	    hex	filename
 993144	  16915	   1872	1011931	  f70db	busybox_old
 993129	  16915	   1872	1011916	  f70cc	busybox_unstripped

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09 01:49:10 +02:00
Dimitri John Ledkov
45fa3f18ad wget: implement TLS verification with ENABLE_FEATURE_WGET_OPENSSL
When ENABLE_FEATURE_WGET_OPENSSL is enabled, correctly implement TLS
verification by default. And only ignore verification errors, if
--no-check-certificate was passed.

Also note, that previously OPENSSL implementation did not implement
TLS verification, nor printed any warning messages that verification
was not performed.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1879533

CVE-2018-1000500

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-05-20 15:10:44 +02:00
Ron Yorston
d1b75e1842 httpd: permit non-default home directory with NOMMU enabled
When BusyBox is compiled with NOMMU enabled running httpd with
the '-h' option fails even if the specified directory exists:

   $ ls -d www
   www
   $ busybox httpd  -fvvvp 8080 -h www
   ...
   ... try to access http://localhost:8080/www
   ...
   httpd: can't change directory to 'www': No such file or directory

The parent process executes xchdir("www").  When a connection is accepted
it's handled by re-executing httpd in inetd mode.  The child process
inherits the current directory "www" and tries to change directory again
to "www", which fails.

Omit the call to xchdir() when httpd is re-executed.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-04-30 16:37:44 +02:00
Denys Vlasenko
adc540f0db tftp: on download, open local file only when first bit of data arrived
No reason to potentially clobber existing file before absolutely necessary.

function                                             old     new   delta
tftp_protocol                                       1947    2020     +73
tftp_main                                            393     376     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 73/-17)             Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-13 15:27:23 +01:00
Denys Vlasenko
0c4e5977df tftp: fix thinko in code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-13 15:03:12 +01:00
Denys Vlasenko
779df9f228 tftp: code shrink
function                                             old     new   delta
tftp_protocol                                       1949    1947      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-13 13:01:43 +01:00
Denys Vlasenko
260bd21169 tftpd: show requested file name in open error message
function                                             old     new   delta
tftp_protocol                                       1902    1949     +47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-13 12:58:46 +01:00
Denys Vlasenko
020abc8856 udhcpd: mangle hostnames starting with dash ("-option")
function                                             old     new   delta
add_lease                                            316     328     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-14 17:07:18 +01:00
Denys Vlasenko
9ec836c033 whois: limit total length of response to 32+2 kb
function                                             old     new   delta
query                                                517     554     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-12-03 14:52:17 +01:00
Denys Vlasenko
ea096d6c13 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>
2019-10-30 12:18:07 +01:00
Jo-Philipp Wich
6b4960155e 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>
2019-10-27 17:07:35 +01:00
Jo-Philipp Wich
8c3b520d4f 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>
2019-10-27 17:02:08 +01:00
Denys Vlasenko
d6ff27de15 ntpd: abs(tmx.offset) was truncating a "long" typed value
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 17:35:58 +02:00
Denys Vlasenko
b4ad1d86b6 tc: array address is never NULL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 13:41:31 +02:00
Denys Vlasenko
e076162897 traceroute: fix gcc-ism
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 13:39:41 +02:00
Denys Vlasenko
e5897d041d suppress a few "unused function" warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 13:05:15 +02:00
Denys Vlasenko
1f1492bb96 netstat: suppress a warning (conversion from 'int' to 'smallint' changes value)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 13:00:01 +02:00
Denys Vlasenko
95867147f5 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>
2019-10-18 16:47:37 +02:00
Denys Vlasenko
37a9008f8e 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>
2019-10-15 12:31:54 +02:00
Denys Vlasenko
eb1395147a brctl: tweak help text, fix comments
function                                             old     new   delta
packed_usage                                       33255   33236     -19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-12 19:51:46 +02:00
Denys Vlasenko
b4fa16d5ed 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>
2019-10-12 19:42:37 +02:00
Denys Vlasenko
3398753818 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>
2019-10-12 19:24:38 +02:00
Martin Lewis
6dcf563633 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>
2019-10-11 17:58:15 +02:00
Michal Kazior
1f1988d525 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>
2019-10-08 15:14:46 +02:00
Martin Lewis
6c1af283f7 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>
2019-10-08 14:43:51 +02:00
Tomas Paukrt
4527273f1c 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>
2019-10-08 13:52:12 +02:00
Denys Vlasenko
65741d004e telnet: fix uninitialized variable bug
function                                             old     new   delta
telnet_main                                         1236    1238      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-25 13:48:01 +02:00
Denys Vlasenko
11e024aa86 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>
2019-09-24 14:01:00 +02:00
David Demelier
4a9daf2b93 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>
2019-09-12 12:09:30 +02:00
Eivind Versvik
22a6339627 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>
2019-08-24 17:24:40 +02:00
Denys Vlasenko
4f70a32f46 udhcpc6: s/iphdr/ip6_hdr/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-08-09 20:43:40 +02:00
Denys Vlasenko
b694608429 ntpd: add comment about mode6, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:03:47 +02:00
Denys Vlasenko
c0961e09b2 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>
2019-07-02 13:10:19 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'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>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
caecfdc20d ntpd: abort if argvs are (unexpectedly) given
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:28:18 +02:00
Denys Vlasenko
84d38500a7 udhcpc: fix comment, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-13 10:02:03 +02:00
Denys Vlasenko
72f12acb6b udhcpc6: fix aliasing warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-11 18:18:48 +02:00
Martin Lewis
d378fa170a 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>
2019-06-11 17:18:28 +02:00
Denys Vlasenko
894f0a3235 tftp: allow -lc and -cl options
function                                             old     new   delta
tftp_main                                            394     396      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 12:41:17 +02:00
Denys Vlasenko
94ce1c0ebb tftpd: revert erroneous change
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 11:32:23 +02:00
Denys Vlasenko
3b8025f132 tftp: optional tftp-hpa compat
function                                             old     new   delta
tftp_main                                            276     394    +118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-09 11:12:02 +02:00
Denys Vlasenko
04a0b7f080 bc: placate compiler warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08 12:58:16 +02:00
Denys Vlasenko
3e463e1cfd brctl: placate compiler warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08 12:35:06 +02:00
Denys Vlasenko
1230aec77a httpd: .js is "application/javascript", not "application/x-javascript"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 12:32:30 +02:00
Denys Vlasenko
5c317c0b8d httpd: add js to built in MIME types list
Firefox needs this to execute .js

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 09:32:03 +02:00
Vicente Jimenez Aguilar
09b25ecc51 httpd: add svg to built in MIME types list
Signed-off-by: Vicente Jimenez Aguilar <googuy@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 09:31:57 +02:00
Denys Vlasenko
45e3967c20 libbb: move netlink socket binding to the utility function
function                                             old     new   delta
create_and_bind_to_netlink                             -     134    +134
ifplugd_main                                        1117    1052     -65
uevent_main                                          399     306     -93
mdev_main                                            314     215     -99
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257)         Total: -123 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03 14:16:52 +02:00