Denys Vlasenko
d417193cf3
shell: avoid segfault on ${0::0/0~09J}. Closes 15216
...
function old new delta
evaluate_string 1011 1053 +42
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-12 17:48:47 +02:00
Denys Vlasenko
bab8828b0d
hush: fix expansion of space in "a=${a:+$a }c" construct
...
function old new delta
encode_then_append_var_plusminus 554 552 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-12 16:39:32 +02:00
Denys Vlasenko
8f0e4c42c6
udhcpd: optional BOOTP support
...
from Adam Goldman <adamg@pobox.com>
This patch makes udhcpd respond correctly to queries from BOOTP clients.
It contains the following changes:
The end field, or DHCP_END option, is required in DHCP requests but
optional in BOOTP requests. However, we still send an end
field in all replies, because some BOOTP clients expect one in replies
even if they didn't send one in the request.
Requests without a DHCP_MESSAGE_TYPE are recognized as BOOTP requests
and handled appropriately, instead of being discarded. We still require
an RFC 1048 options field, but we allow it to be empty.
Since a BOOTP client will keep using the assigned IP forever, we only
send a BOOTP reply if a static lease exists for that client.
BOOTP replies shouldn't contain DHCP_* options, so we omit them if there
was no DHCP_MESSAGE_TYPE in the request. Options other than DHCP_*
options are still sent.
The options field of a BOOTP reply must be exactly 64 bytes. If we
construct a reply with more than 64 bytes of options, we give up and log
an error instead of sending it. udhcp_send_raw_packet already pads the
options field to 64 bytes if it is too short.
This implementation has been tested against an HP PA-RISC client.
function old new delta
.rodata 105247 105321 +74
udhcpd_main 1520 1591 +71
send_offer 419 470 +51
init_packet 81 97 +16
udhcp_init_header 75 88 +13
udhcp_scan_options 192 203 +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 236/0) Total: 236 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-12 13:22:47 +02:00
Denys Vlasenko
4bd70463c7
libbb: pass "" rather than NULL as format string in _nomsg functions
...
function old new delta
bb_perror_nomsg_and_die 9 10 +1
bb_perror_nomsg 9 10 +1
bb_verror_msg 480 469 -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 2/-11) Total: -9 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-12 10:19:29 +02:00
Denys Vlasenko
2ca39ffd44
awk: fix subst code to handle "start of word" pattern correctly (needs REG_STARTEND)
...
function old new delta
awk_sub 637 714 +77
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-08 10:42:39 +02:00
Denys Vlasenko
113685fbcd
awk: fix SEGV on read error in -f PROGFILE
...
function old new delta
awk_main 829 843 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-07 10:54:34 +02:00
Denys Vlasenko
f4789164e0
awk: code shrink
...
function old new delta
awk_sub 544 548 +4
exec_builtin 1136 1130 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-6) Total: -2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-06 12:48:11 +02:00
Denys Vlasenko
5f84c56336
awk: fix backslash handling in sub() builtins
...
function old new delta
awk_sub 559 544 -15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-03 00:42:10 +02:00
Denys Vlasenko
0256e00a9d
awk: fix precedence of = relative to ==
...
Discovered while adding code to disallow assignments to non-lvalues
function old new delta
parse_expr 936 991 +55
.rodata 105243 105247 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 59/0) Total: 59 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-30 16:44:04 +02:00
Denys Vlasenko
fe0b798548
tunctl: code shrink
...
function old new delta
.rodata 105246 105243 -3
tunctl_main 349 344 -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-8) Total: -8 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-29 14:47:10 +02:00
Denys Vlasenko
721bf6eaf4
awk: printf(INVALID_FMT) prints it verbatim
...
function old new delta
awk_printf 628 640 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-29 10:55:40 +02:00
Denys Vlasenko
4d7339204f
awk: shrink - use setvar_sn() to set variables from non-NUL terminated strings
...
function old new delta
setvar_sn - 39 +39
exec_builtin 1145 1136 -9
awk_getline 591 559 -32
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 39/-41) Total: -2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-28 18:08:06 +02:00
Denys Vlasenko
05e60007d4
awk: code shrink
...
function old new delta
awk_getline 620 591 -29
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-28 17:51:59 +02:00
Denys Vlasenko
b76b420b5d
awk: fix closing of non-opened file
...
function old new delta
setvar_ERRNO - 53 +53
.rodata 105252 105246 -6
awk_getline 639 620 -19
evaluate 3402 3377 -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 53/-50) Total: 3 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-28 17:25:56 +02:00
Denys Vlasenko
9790eb73c8
libbb/dump: code shrink
...
function old new delta
.rodata 105252 105246 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-28 13:32:07 +02:00
Denys Vlasenko
21dce1c3c3
awk: do not read ARGIND, only set it (gawk compat)
...
function old new delta
next_input_file 216 243 +27
evaluate 3396 3402 +6
awk_main 826 829 +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 36/0) Total: 36 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-27 19:11:28 +02:00
Denys Vlasenko
5c8a9dfd97
awk: remove a local variable "caching" a struct member
...
Since we take its address, the variable lives on stack (not a GPR).
Thus, nothing is improved by caching it.
function old new delta
awk_getline 642 639 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-27 18:21:38 +02:00
Denys Vlasenko
528808bcd2
awk: get rid of one indirection level for iF (input file structure)
...
function old new delta
try_to_assign - 91 +91
next_input_file 214 216 +2
awk_main 827 826 -1
evaluate 3403 3396 -7
is_assignment 91 - -91
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/2 up/down: 93/-99) Total: -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-27 18:05:42 +02:00
Denys Vlasenko
84ff1825dd
awk: fix splitting with default FS
...
function old new delta
awk_split 543 544 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-27 16:17:38 +02:00
Denys Vlasenko
9225f9684f
libbb/dump: make xxd_displayoff member conditional on xxd
...
With xxd not selected:
function old new delta
display 1459 1444 -15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-27 14:52:17 +02:00
Denys Vlasenko
6d9427420b
od: -l,I,L indeed depend on sizeof(long), fix this
...
function old new delta
.rodata 105255 105252 -3
od_main 1917 1901 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 20:17:04 +02:00
Denys Vlasenko
5dcc443dba
awk: fix use-after-realloc (CVE-2021-42380), closes 15601
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 19:36:58 +02:00
Denys Vlasenko
d7814f5727
hexdump: code shrink
...
function old new delta
add_format - 50 +50
add_first 10 - -10
hexdump_main 401 366 -35
.rodata 105306 105255 -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 50/-96) Total: -46 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 16:43:40 +02:00
Denys Vlasenko
283cba78f2
hexdump, xxd: shrink strings
...
function old new delta
add_first 12 10 -2
.rodata 105321 105306 -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-17) Total: -17 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 14:46:29 +02:00
Denys Vlasenko
34751d8bf9
libbb/dump: correct handling of 1-byte signed int format
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 14:10:38 +02:00
Denys Vlasenko
8fab211141
libbb/dump: use fputs_stdout where appropriate
...
function old new delta
display 1485 1483 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 13:39:33 +02:00
Denys Vlasenko
de851bc9b2
od, hexdump: byte 0x11 is "dc1" not "dcl"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 13:33:08 +02:00
Denys Vlasenko
25a10ffe1f
od: actually remove -IL from --help, as comment says
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 13:01:41 +02:00
Denys Vlasenko
60d4d55b87
od: support -DOHXIL
...
function old new delta
od_main 1866 1917 +51
.rodata 105306 105321 +15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 66/0) Total: 66 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 12:56:17 +02:00
Denys Vlasenko
3c6f6382ee
libbb/dump: conditionalize code used only by xxd and od
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 12:34:11 +02:00
Denys Vlasenko
aa4d303a31
od: fix default format, shrink
...
function old new delta
od_main 556 568 +12
.rodata 104613 104555 -58
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-58) Total: -46 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-26 04:27:43 +02:00
Denys Vlasenko
0c3270f7e5
od: stop printing extra trailing spaces
...
function old new delta
.rodata 104598 104613 +15
display 1475 1485 +10
od_main 549 556 +7
rewrite 971 967 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 32/-4) Total: 28 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 23:48:13 +02:00
Denys Vlasenko
6882a933cf
od: implement -B
...
function old new delta
.rodata 105305 105306 +1
od_main 1880 1866 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-14) Total: -13 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 22:17:18 +02:00
Denys Vlasenko
ce4cfc33ca
od: correct -i, enable tests which pass for DESKTOP too
...
function old new delta
.rodata 105302 105305 +3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 19:51:37 +02:00
Denys Vlasenko
e2287f99fe
od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -s
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 17:40:20 +02:00
David Leonard
64bdd7566c
od: add tests
...
* Added tests for od (non-DESKTOP little-endian)
* Allow 'optional' to invert meaning of a config option with '!'
Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:32:03 +02:00
David Leonard
2bda790fd1
od: fix -O
...
od with option -O (4-byte octal) was incorrectly displaying 2-byte
decimal when built without CONFIG_DESKTOP
Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:32:03 +02:00
Denys Vlasenko
b5be8da350
hush: make "false" built-in
...
function old new delta
bltins1 384 396 +12
builtin_false - 6 +6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 18/0) Total: 18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 15:24:56 +02:00
Denys Vlasenko
6824298ab4
hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571
...
function old new delta
run_list 1012 1024 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-25 14:22:10 +02:00
Karsten Sperling
3e83699ce2
ash: use-after-free in bash pattern substitution
...
Commit daa66ed6
fixed a number of use-after-free bugs in bash pattern
substitution, however one "unguarded" STPUTC remained, which is fixed here.
function old new delta
subevalvar 1564 1576 +12
Signed-off-by: Karsten Sperling <ksperling@apple.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-18 16:49:54 +02:00
Denys Vlasenko
c5682813ab
examples/var_service/README: fix an error
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-18 13:30:10 +02:00
Denys Vlasenko
2f663a6f7d
cpio: tweak --help
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 20:35:16 +02:00
Denys Vlasenko
dc84002a82
nslookup: code shrink
...
function old new delta
send_queries 725 723 -2
nslookup_main 822 820 -2
add_query 89 86 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-7) Total: -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 19:32:29 +02:00
Denys Vlasenko
62775ec4b3
nslookup: ensure unique transaction IDs for the DNS queries
...
Based on patch by Uwe Kleine-König.
It makes sense to actually see the nitty-gritty details of DNS
querying, so bringing in (commented-out) musl's DNS request code.
function old new delta
nslookup_main 760 822 +62
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 19:21:45 +02:00
Denys Vlasenko
3a7f00eadc
hush: add comment about abort on syntax error %{^}
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-09 14:02:06 +02:00
Denys Vlasenko
465f05a420
build system: fix "Config.in:117 error: Overlong line"
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-08 12:31:34 +02:00
Denys Vlasenko
3c8e540eb7
hush: fix an interactive abort on error
...
function old new delta
parse_and_run_stream 140 155 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-08 12:27:50 +02:00
Uwe Kleine-König
40fa8eb998
build system: Make it possible to build with 64bit time_t
...
On most 32bit architectures time_t (and a few other time related types)
are a signed 32bit wide integer type.
As a consequence they can only represent dates between
Fri Dec 13 08:45:52 PM UTC 1901
(-0x80000000 seconds before Jan 1 1970) and
Tue Jan 19 03:14:07 AM UTC 2038
(0x7fffffff seconds after Jan 1 1970). Given that some machines that are
built today have an expected lifetime of >15 years, this needs to be
extended. To to that, define the cpp symbol _TIME_BITS to 64 which
results in some magic in glibc to make time_t (and the few other time
related types) 64 bit wide.
This new switch CONFIG_TIME64 is in the spirit of CONFIG_LFS and only
expected to have the expected effect with glibc. On musl for examples
time_t already defaults to 64bit wide types.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:57:06 +02:00
Denys Vlasenko
07f8b6feac
readlink: code shrink
...
function old new delta
readlink_main 111 103 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:44:03 +02:00
Denys Vlasenko
c6058d221a
nmeter: improve %T fractionals display
...
function old new delta
nmeter_main 751 786 +35
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-05-07 18:35:22 +02:00