summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-12-25sed: do not ignore 'g' modifier when match starts with ^Dominique Martinet
It is perfectly valid to start a regex with ^ and have other patterns with \| that can match more than once, e.g. the following example should print ca, as illustrated with gnu sed: $ echo 'abca' | sed -e 's/^a\|b//g' ca busybox before patch: $ echo 'abca' | busybox sed -e 's/^a\|b//g' bca busybox after patch: $ echo 'abca' | ./busybox sed -e 's/^a\|b//g' ca regcomp handles ^ perfectly well as illustrated with the second 'a' that did not match in the example, we ca leave the non-repeating to it if appropriate. The check had been added before using regcomp and was required at the time (f36635cec6da) but no longer makes sense now. (tested with glibc and musl libc) function old new delta add_cmd 1189 1176 -13 Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-19ed: align output of read command with POSIX.1-2008Sören Tempel
POSIX.1-2008 mandates the following regarding the read command: If the read is successful, and -s was not specified, the number of bytes read shall be written to standard output in the following format: "%d\n", <number of bytes read> This commit aligns the output of busybox ed with POSIX.1-2008 by removing the file name from the output for the read command. This slipped through in 4836a0708fd0aaeb82871a3762b40fcf4b61e812. function old new delta .rodata 104203 104196 -7 readLines 409 388 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-28) Total: -28 bytes Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-19ed: fix current line number for file passed via the command-lineSören Tempel
POSIX.1-2008 mandates the following regarding the file command-line argument: If the file argument is given, ed shall simulate an e command on the file named by the pathname […] The specification for the e command mandates the following behaviour regarding the current line number in POSIX.1-2008: The current line number shall be set to the address of the last line of the buffer. However, without this commit, busybox ed will set the current line number to 1 if a file is given on the command-line and this file is not empty (lastNum != 0). This is incorrect and fixed in this commit by not modifying the current line number in ed_main(). As such, the current line number will be zero for empty files and otherwise be set to the address of the last line of the buffer. function old new delta ed_main 144 128 -16 Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17timeout: add support for "timeout -k KILL_SECS"Matthew Slowe
function old new delta timeout_main 307 373 +66 timeout_wait - 42 +42 .rodata 104201 104203 +2 packed_usage 34097 34096 -1 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 110/-1) Total: 109 bytes Signed-off-by: Matthew Slowe <foo@mafoo.org.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17cmp: code shrinkDenys Vlasenko
function old new delta .rodata 104203 104201 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17ed: add support for -p command-line option as mandated by POSIXSören Tempel
The POSIX.1-2008 specification of ed(1) mandates two command-line options: -p (for specifying a prompt string) and -s (to suppress writing of byte counts). This commit adds support for the former. Furthermore, it also changes the default prompt string to an empty string (instead of ": ") since this is also mandated by POSIX: -p string Use string as the prompt string when in command mode. By default, there shall be no prompt string. function old new delta ed_main 112 144 +32 packed_usage 34074 34097 +23 doCommands 1889 1887 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 55/-2) Total: 53 bytes Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17cmp: add support for -nWalter Lozano
Add support to for "-n" to cmp in order to compare at most n bytes. function old new delta cmp_main 552 589 +37 .rodata 104198 104203 +5 packed_usage 34102 34074 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 42/-28) Total: 14 bytes Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17docs/embedded-scripts.txt: whitespace fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17find: implement -samefileAaro Koskinen
function old new delta parse_params 1461 1606 +145 func_samefile - 42 +42 packed_usage 34079 34102 +23 static.params 261 271 +10 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 220/0) Total: 220 bytes Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17printf: allow 0 as a flag and allow multiple flagsRon Yorston
The '%' character in a format specification may be followed by one or more flags from the list "+- #0". BusyBox printf didn't support the '0' flag or allow multiple flags to be provided. As a result the formats '%0*d' and '%0 d' were considered to be invalid. The lack of support for '0' was pointed out by Andrew Snyder on the musl mailing list: https://www.openwall.com/lists/musl/2021/12/14/2 function old new delta printf_main 860 891 +31 .rodata 99281 99282 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17httpd: do not send Last-Modified / ETag / Content-Length for error pagesDenys Vlasenko
function old new delta send_headers 713 701 -12 send_headers_and_exit 20 34 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17httpd: don't send Content-Length in error pages headerDenys Vlasenko
function old new delta send_headers 701 713 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12libarchive/get_header_ar.c: fix extraction of archives from binutils in ↵Peter Korsgaard
deterministic mode GNU binutils in deterministic mode (ar rD or built with --enable-deterministic-archives) hard codes file mode to 0644 (NOT 0100644) since https://github.com/bminor/binutils-gdb/commit/36e4dce69dd2 This confuses busybox ar x (data_extract_all): touch a; ar rD a.ar a ar: creating a.ar busybox ar x a.ar ar: unrecognized file type hexdump -C a.ar 00000000 21 3c 61 72 63 68 3e 0a 61 2f 20 20 20 20 20 20 |!<arch>.a/ | 00000010 20 20 20 20 20 20 20 20 30 20 20 20 20 20 20 20 | 0 | 00000020 20 20 20 20 30 20 20 20 20 20 30 20 20 20 20 20 | 0 0 | 00000030 36 34 34 20 20 20 20 20 30 20 20 20 20 20 20 20 |644 0 | 00000040 20 20 60 0a | `.| As a workaround, force the mode bits to S_IFREG, as nothing else makes sense for ar. function old new delta get_header_ar 539 542 +3 Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12udhcpc6: fix udhcp_find_option to actually find DHCP6 optionsDenys Vlasenko
udhcp_insert_new_option treats code for IPv6 as follows: new->data[D6_OPT_CODE] = code >> 8; new->data[D6_OPT_CODE + 1] = code & 0xff; udhcp_find_option tests the code as follows: while (opt_list && opt_list->data[OPT_CODE] < code) ... if (opt_list && opt_list->data[OPT_CODE] == code) So yes, OPT_CODE and D6_OPT_CODE are both 0, but the D6_OPT_CLIENTID = 1 value means that the 1 is in the seconds byte, and udhcp_find_option is only looking at the first byte, So the send_d6_release can never find it the created option. function old new delta udhcp_find_option 28 53 +25 attach_option 276 284 +8 udhcpc6_main 2602 2607 +5 perform_d6_release 262 267 +5 udhcpd_main 1518 1520 +2 udhcpc_main 2542 2544 +2 add_serverid_and_clientid_options 46 48 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/0 up/down: 49/0) Total: 49 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12Makefile.flags: use all cflags for crypt and rt checksMartin Kaiser
To check if libcrypt and librt are available, we check if we can compile and link a simple test program. These checks do not match the actual linking if CONFIG_STATIC is enabled. For CONFIG_STATIC, CFLAGS_busybox is set to -static. The checks don't use CFLAGS_busybox and detect a shared libcrypt or librt. If we link busybox later and we have no static libcrypt or librt, linking will fail. Update the libcrypt and librt checks to use CFLAGS_busybox. Signed-off-by: Martin Kaiser <martin@kaiser.cx> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12wget: allow end-users to customize Content-Type for --post-data and --post-fileIldar Shaimordanov
More explanation in this PR: https://github.com/rmyorston/busybox-w32/pull/233 The real use-case: wget https://api.github.com/markdown/raw --header "Content-Type: text/plain" function old new delta wget_main 2560 2581 +21 wget_user_headers 62 76 +14 .rodata 104196 104197 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 36/0) Total: 36 bytes Signed-off-by: Ildar Shaimordanov <ildar.shaimordanov@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12uudecode: special-case "/dev/stdout", closes 14241Denys Vlasenko
function old new delta uudecode_main 295 322 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-11tls: P256: factor out "multiply then reduce" operationDenys Vlasenko
function old new delta sp_256_mont_mul_and_reduce_8 - 44 +44 sp_256_ecc_mulmod_8 517 442 -75 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 44/-75) Total: -31 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-01tls: x25519: code shrink by factoring out common codeDenys Vlasenko
function old new delta fe_reduce - 37 +37 lm_add 67 43 -24 fe_mul_c 62 38 -24 fe_mul__distinct 138 112 -26 curve25519 800 767 -33 lm_sub 98 64 -34 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/5 up/down: 37/-141) Total: -104 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28tls: P256: enable 64-bit version of montgomery reductionDenys Vlasenko
After more testing, (1) I'm more sure it is indeed correct, and (2) it is a significant speedup - we do a lot of those multiplications. function old new delta sp_512to256_mont_reduce_8 191 223 +32 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28tls: P256: add 64-bit montgomery reduce (disabled), small optimization in ↵Denys Vlasenko
32-bit code function old new delta sp_512to256_mont_reduce_8 191 185 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28tls: P256: add comment on logic in sp_512to256_mont_reduce_8, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28libbb: code shrink in des encryption, in setup_salt()Denys Vlasenko
function old new delta pw_encrypt 978 971 -7 .rodata 108208 108192 -16 des_crypt 1211 1181 -30 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-53) Total: -53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28tls: P256: simplify sp_256_mont_inv_8 (no need for a temporary)Denys Vlasenko
function old new delta sp_256_ecc_mulmod_8 543 517 -26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-28libarchive: remove duplicate forward declarationBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2021-11-28tls: P256: pad struct sp_point to 64 bits (on 64-bit arches)Denys Vlasenko
function old new delta curve_P256_compute_pubkey_and_premaster 198 190 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: trivial x86-64 fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: change logic so that we don't need double-wide vectors everywhereDenys Vlasenko
Change sp_256to512z_mont_{mul,sqr}_8 to not require/zero upper 256 bits. There is only one place where we actually used that (and that's why there used to be zeroing memset of top half!). Fix up that place. As a bonus, 256x256->512 multiply no longer needs to care for "r overlaps a or b" case. This shrinks sp_point structure as well, not just temporaries. function old new delta sp_256to512z_mont_mul_8 150 - -150 sp_256_mont_mul_8 - 147 +147 sp_256to512z_mont_sqr_8 7 - -7 sp_256_mont_sqr_8 - 7 +7 sp_256_ecc_mulmod_8 494 543 +49 sp_512to256_mont_reduce_8 243 249 +6 sp_256_point_from_bin2x32 73 70 -3 sp_256_proj_point_dbl_8 353 345 -8 sp_256_proj_point_add_8 544 499 -45 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/3 up/down: 209/-213) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: do not open-code copying of struct variablesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: fix sp_256_div2_8 - it wouldn't use a[] if low bit is 0Denys Vlasenko
It worked by chance because the only caller passed both parameters as two pointers to the same array. My fault (I made this error when converting from 26-bit code). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: remove redundant zeroing in sp_256_map_8Denys Vlasenko
Previous change made it obvious that we zero out already-zeroed high bits function old new delta sp_256_ecc_mulmod_8 534 494 -40 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: explain which functions use double-wide arrays, no code changesDenys Vlasenko
function old new delta sp_512to256_mont_reduce_8 - 243 +243 sp_256to512z_mont_mul_8 - 150 +150 sp_256to512z_mont_sqr_8 - 7 +7 sp_256_mont_sqr_8 7 - -7 sp_256_mont_mul_8 150 - -150 sp_256_mont_reduce_8 243 - -243 ------------------------------------------------------------------------------ (add/remove: 3/3 grow/shrink: 0/0 up/down: 400/-400) Total: 0 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: remove constant-time trick in sp_256_proj_point_add_8Denys Vlasenko
function old new delta sp_256_proj_point_add_8 576 544 -32 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: do not open-code copying of struct variablesDenys Vlasenko
function old new delta sp_256_ecc_mulmod_8 536 534 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: tweak debug printoutDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27tls: P256: 64-bit optimizationsDenys Vlasenko
function old new delta sp_256_proj_point_dbl_8 421 428 +7 sp_256_point_from_bin2x32 78 84 +6 sp_256_cmp_8 38 42 +4 sp_256_to_bin_8 28 31 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 20/0) Total: 20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-09which: add -a to help textDenys Vlasenko
function old new delta packed_usage 34075 34079 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13cpio: add support for --renumber-inodes like GNU cpioAriadne Conill
The --renumber-inodes option renumbers the inodes starting from 1, so that the sequence of inodes is always stable. This helps with reproducibility. function old new delta cpio_o 961 1045 +84 .rodata 78422 78440 +18 bbconfig_config_bz2 6168 6164 -4 packed_usage 25764 25756 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 102/-12) Total: 90 bytes Signed-off-by: Ariadne Conill <ariadne@dereferenced.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13cpio: add support for --ignore-devno like GNU cpioAriadne Conill
The --ignore-devno option is used to set device numbers to (0, 0). This can be useful in verifying whether a CPIO archive is reproducible. function old new delta cpio_o 922 961 +39 .rodata 78407 78422 +15 bbconfig_config_bz2 6161 6167 +6 packed_usage 25770 25764 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 60/-6) Total: 54 bytes Signed-off-by: Ariadne Conill <ariadne@dereferenced.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13shell: tweak --helpDenys Vlasenko
Even though formally it is -s [ARGS], "sh -s" without ARGS is the same as just "sh". And we are already over 80 chars wide for ash --help, so make it shorter. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-13hush: in a comment, document what -i might be doingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12ed: align output of read/write commands with POSIX-1.2008Sören Tempel
POSIX.1-2008 mandates the following regarding the write command: If the command is successful, the number of bytes written shall be written to standard output, unless the -s option was specified, in the following format: "%d\n", <number of bytes written> function old new delta readLines 447 409 -38 doCommands 1940 1889 -51 .rodata 104219 104163 -56 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-145) Total: -145 bytes Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12config system: move some options closer to relevalnt tool subdirectoriesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12shell: use more compact SHELL_ASH / HUSH config defines. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11shell: do not read user database for every prompt - only for those which need itDenys Vlasenko
function old new delta get_user_strings - 52 +52 get_homedir_or_NULL - 23 +23 parse_and_put_prompt 823 838 +15 null_str 1 - -1 complete_cmd_dir_file 814 812 -2 deinit_S 51 42 -9 read_line_input 3059 3015 -44 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 1/3 up/down: 90/-56) Total: 34 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11tar: prevent malicious archives with enormous long name sizes OOMing the machineDenys Vlasenko
function old new delta get_header_tar 1707 1752 +45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11whitespace fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=yDenys Vlasenko
function old new delta re_execed_comm - 46 +46 main 72 86 +14 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11tls: code shrink curve25519Denys Vlasenko
function old new delta fe_select 39 - -39 curve25519 849 800 -49 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-88) Total: -88 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11tls: remove unused tls_symmetric.h (was used by old "big" AES code)Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>