oweals/busybox.git
6 years agohush: fix dup_CLOEXEC() call without "avoid_fd" parameter
Denys Vlasenko [Tue, 26 Jun 2018 13:50:33 +0000 (15:50 +0200)]
hush: fix dup_CLOEXEC() call without "avoid_fd" parameter

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofdisk: placate warning of strncpy not copying NUL byte
Denys Vlasenko [Tue, 26 Jun 2018 13:44:58 +0000 (15:44 +0200)]
fdisk: placate warning of strncpy not copying NUL byte

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix for !ENABLE_HUSH_MODE_X configuration
Denys Vlasenko [Tue, 26 Jun 2018 13:43:56 +0000 (15:43 +0200)]
hush: fix for !ENABLE_HUSH_MODE_X configuration

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: variable nesting code is used also if HUSH_FUNCTIONS is not enabled
Denys Vlasenko [Tue, 26 Jun 2018 13:36:58 +0000 (15:36 +0200)]
hush: variable nesting code is used also if HUSH_FUNCTIONS is not enabled

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorandomconfig fixes
Denys Vlasenko [Tue, 26 Jun 2018 13:35:17 +0000 (15:35 +0200)]
randomconfig fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotls: fix to handle X.509 v1 certificates correctly
Ivan Abrea [Sun, 24 Jun 2018 18:04:57 +0000 (20:04 +0200)]
tls: fix to handle X.509 v1 certificates correctly

The syntax of public key certificates can be found in RFC 5280 section
4.1. The relevant part of the syntax is the following:

  TBSCertificate  ::=  SEQUENCE  {
    version         [0]  EXPLICIT Version DEFAULT v1,
    serialNumber         CertificateSerialNumber,
    ... remaining fields omitted ...
  }

The version field has a default value of v1. RFC 5280 section 4.1.2.1
says the following:

  If only basic fields are present, the version SHOULD be 1 (the value
  is omitted from the certificate as the default value); however, the
  version MAY be 2 or 3.

To help detect if the version field is present or not, the type of the
version field has an explicit tag of [0]. Due to this tag, if the
version field is present, its encoding will have an identifier octet
that is distinct from that of the serialNumber field.

ITU-T X.690 specifies how a value of such a type should be encoded with
DER. There is a PDF of X.690 freely available from ITU-T. X.690 section
8.1.2 specifies the format of identifier octets which is the first
component of every encoded value. Identifier octets encode the tag of a
type. Bits 8 and 7 encode the tag class. Bit 6 will be 0 if the encoding
is primitive and 1 if the encoding is constructed. Bits 5 to 1 encode
the tag number.

X.690 section 8.14 specifies what the identifier octet should be for
explicitly tagged types. Section 8.14.3 says if implicit tagging is not
used, then the encoding shall be constructed. The version field uses
explicit tagging and not implicit tagging, so its encoding will be
constructed. This means bit 6 of the identifier octet should be 1.

X.690 section 8.14 and Annex A provide examples. Note from their
examples that the notation for tags could look like [APPLICATION 2]
where both the tag class and tag number are given. For this example, the
tag class is 1 (application) and the tag number is 2. For notation like
[0] where the tag class is omitted and only the tag number is given, the
tag class will be context-specific.

Putting this all together, the identifier octet for the DER encoding of
the version field should have a tag class of 2 (context-specific), bit 6
as 1 (constructed), and a tag number of 0.

Signed-off-by: Ivan Abrea <ivan@algosolutions.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agontpd: deprecate IPTOS_LOWDELAY in favor of IPTOS_DSCP_AF21
Codarren Velvindron [Sun, 15 Apr 2018 16:37:50 +0000 (20:37 +0400)]
ntpd: deprecate IPTOS_LOWDELAY in favor of IPTOS_DSCP_AF21

Update QoS markers.
Use DSCP AF21 for interactive traffic. DSCP is defined in RFC2474.
Many modern equipment no longer support IPTOS.

Signed-off-by: Codarren Velvindron <codarren@hackers.mu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples: update /var/service/getty for Unicode ttys
Denys Vlasenko [Sat, 23 Jun 2018 11:55:13 +0000 (13:55 +0200)]
examples: update /var/service/getty for Unicode ttys

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoinstall: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106
Denys Vlasenko [Fri, 22 Jun 2018 16:59:10 +0000 (18:59 +0200)]
install: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106

function                                             old     new   delta
install_main                                         758     767      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc: remove code which requires server ID to be on local network
Denys Vlasenko [Thu, 21 Jun 2018 15:36:22 +0000 (17:36 +0200)]
udhcpc: remove code which requires server ID to be on local network

This reverts "udhcpc: paranoia when using kernel UDP mode
for sending renew: server ID may be bogus".

Users complain that they do have servers behind routers
(with DHCP relays).

function                                             old     new   delta
send_packet                                          168     166      -2
bcast_or_ucast                                        25      23      -2
udhcp_send_kernel_packet                             301     295      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-10)             Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoUpdate release script to generate detached signatures and checksum files
Eli Schwartz [Tue, 5 Jun 2018 16:48:53 +0000 (12:48 -0400)]
Update release script to generate detached signatures and checksum files

This is more usable for programmatically checking the validity of a
release.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorestore documentation on the build config language
Kartik Agaram [Fri, 1 Jun 2018 05:15:55 +0000 (22:15 -0700)]
restore documentation on the build config language

Kconfig-language.txt was deleted in commit 4fa499a17b52b back in 2006.
Move to docs/ as suggested by Xabier Oneca:
  http://lists.busybox.net/pipermail/busybox/2014-May/080914.html
Also update references to it everywhere.

Signed-off-by: Kartik Agaram <akkartik@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: emit a message that certificate verification is not implemented
Denys Vlasenko [Mon, 28 May 2018 12:36:26 +0000 (14:36 +0200)]
wget: emit a message that certificate verification is not implemented

function                                             old     new   delta
spawn_ssl_client                                     185     209     +24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofdisk: remove "Partition N does not end on cylinder boundary" message
Denys Vlasenko [Sat, 26 May 2018 16:51:18 +0000 (18:51 +0200)]
fdisk: remove "Partition N does not end on cylinder boundary" message

fdisk from util-linux 2.31 (maybe earlier) does not print this.

function                                             old     new   delta
check_consistency                                    449     399     -50

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowhitespace fix
Denys Vlasenko [Sat, 26 May 2018 15:42:00 +0000 (17:42 +0200)]
whitespace fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: close another SEGV possibility
Denys Vlasenko [Fri, 25 May 2018 15:03:46 +0000 (17:03 +0200)]
unlzma: close another SEGV possibility

function                                             old     new   delta
unpack_lzma_stream                                  2669    2686     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: carry along length of packet when parsing it.
David Decotigny [Thu, 24 May 2018 15:30:15 +0000 (08:30 -0700)]
udhcpc6: carry along length of packet when parsing it.

This is to avoid parsing garbage past packet's actual end.

Also const-ize params to a few functions.

function                                             old     new   delta
d6_run_script_no_option                                -      12     +12
option_to_env                                        791     798      +7
d6_run_script                                        253     255      +2
perform_d6_release                                    95      93      -2
udhcpc6_main                                        2596    2592      -4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 21/-6)              Total: 15 bytes

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: ignore invalid OPTION_IAADDR
David Decotigny [Thu, 24 May 2018 15:30:16 +0000 (08:30 -0700)]
udhcpc6: ignore invalid OPTION_IAADDR

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agorealpath,readlink -f: coreutils compat, closes 11021
Denys Vlasenko [Thu, 24 May 2018 15:29:14 +0000 (17:29 +0200)]
realpath,readlink -f: coreutils compat, closes 11021

function                                             old     new   delta
xmalloc_realpath_coreutils                             -     121    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonc: fix the !NC_SERVER configuration
Denys Vlasenko [Thu, 24 May 2018 14:38:40 +0000 (16:38 +0200)]
nc: fix the !NC_SERVER configuration

The symptom is the "nc: NO OPT l!" message.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofsck: fix incorrect handling of child exit
Denys Vlasenko [Thu, 24 May 2018 13:26:28 +0000 (15:26 +0200)]
fsck: fix incorrect handling of child exit

In commit

  c4fb8c6a - fsck: do not use statics

not only statics were changed but also a couple of
statics-unrelated changes were made.

This included the handling of the child termination status
as follows:

    - if (WIFEXITED(status))
    -   status = WEXITSTATUS(status);
    - else if (WIFSIGNALED(status)) {
    + status = WEXITSTATUS(status);
    + if (WIFSIGNALED(status)) {

This is wrong, should have used a different variable to hold exit code.

Reported by Niklas Hambüchen <mail@nh2.me>.

function                                             old     new   delta
wait_one                                             294     282     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: fix interaction of delayed symlink and hardlink creation
Harald van Dijk [Tue, 22 May 2018 15:34:31 +0000 (17:34 +0200)]
tar: fix interaction of delayed symlink and hardlink creation

function                                             old     new   delta
create_or_remember_link                                -     106    +106
create_links_from_list                                 -      93     +93
find_applet_by_name                                  124     128      +4
unzip_main                                          2724    2726      +2
data_extract_all                                     891     873     -18
create_symlinks_from_list                             64       -     -64
create_or_remember_symlink                            94       -     -94
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/1 up/down: 205/-176)           Total: 29 bytes

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotweak /var/service example
Denys Vlasenko [Sun, 20 May 2018 20:43:42 +0000 (22:43 +0200)]
tweak /var/service example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agopopmaildir: placate gcc8 "warning: 'strncpy' output truncated"
Denys Vlasenko [Mon, 14 May 2018 09:14:58 +0000 (11:14 +0200)]
popmaildir: placate gcc8 "warning: 'strncpy' output truncated"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: set -x options in request
Denys Vlasenko [Mon, 14 May 2018 09:06:35 +0000 (11:06 +0200)]
udhcpc6: set -x options in request

Last foru commits:

function                                             old     new   delta
option_to_env                                        621     791    +170
.rodata                                           168351  168505    +154
attach_option                                        431     506     +75
add_d6_client_options                                112     167     +55
d6_option_strings                                     30      84     +54
udhcp_str2optset                                     644     660     +16
d6_optflags                                           12      20      +8
udhcpc6_main                                        2590    2596      +6
udhcpc_main                                         2648    2651      +3
read_optset                                           15      18      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 10/0 up/down: 544/0)            Total: 544 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add PXELINUX options
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:13 +0000 (14:29 +1000)]
udhcpc6: add PXELINUX options

Add support for the PXELINUX options 209 ("ConfigFile") and 210
("PathPrefix") in the DHCPv6 client.

See also: RFC5071, "Dynamic Host Configuration Protocol Options Used by
PXELINUX".

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add DHCPv6 boot options
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:12 +0000 (14:29 +1000)]
udhcpc6: add DHCPv6 boot options

Add support for 'bootfile-url' and 'bootfile-params' as defined by
RFC5970 "DHCPv6 Options for Network Boot".

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcpc6: add DHCPv6 env helper
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:11 +0000 (14:29 +1000)]
udhcpc6: add DHCPv6 env helper

Add string_option_to_env() to easily generate environment variables for
known simple options.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: fix use of trim() in udhcp_str2optset()
Samuel Mendoza-Jonas [Mon, 14 May 2018 04:29:15 +0000 (14:29 +1000)]
udhcp: fix use of trim() in udhcp_str2optset()

trim() modifies the string in place if needed and returns a pointer to
the end of the resulting string. Update udhcp_str2optset() so it no
longer sets the value of 'val' to the return value of trim().

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonsenter: fix parsing of -t, -S and -G options
Euan Harris [Fri, 4 May 2018 15:18:47 +0000 (16:18 +0100)]
nsenter: fix parsing of -t, -S and -G options

-t, -S and -G each take mandatory integer arguments.   getopt32long()'s
option string syntax for this type of argument is 'c:+', however nsenter's
opt_str uses 'c+', which specifies two options 'c' and '+' which do not
take arguments.   This means that giving a target PID causes nsenter to
exit and print the usage string:

  # nsenter -t1 sh
  nsenter: unrecognized option: 1
  BusyBox v1.27.2 (2017-12-12 10:41:50 GMT) multi-call binary.
  ...

The long form options are also broken:

  # nsenter --setuid=1000 --setgid=1000 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

`nsenter --target=<pid> sh` parses correctly and appears to work, but
<pid> is ignored and set to 0.   This doesn't raise an error unless one
of the namespace arguments is also given:

  # ./busybox_unstripped nsenter --target=42 sh
  # exit

  # ./busybox_unstripped nsenter -n --target=42 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

This has caused problems in a couple of places:

  https://github.com/linuxkit/linuxkit/issues/567
  https://github.com/gliderlabs/docker-alpine/issues/359
  https://github.com/kontena/pharos-cluster/pull/81

Signed-off-by: Euan Harris <euan.harris@docker.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonsenter: Rename --network option to --net
Euan Harris [Thu, 3 May 2018 12:34:46 +0000 (13:34 +0100)]
nsenter: Rename --network option to --net

In nsenter from util-linux, the long version of the -n option is
--net=<path>.   BusyBox's version expects --network=<path>, so scripts
and examples written for util-linux's version cause BusyBox's version
to exit with the usage message.

Confusingly, until commit 036585a911a5f, the usage message erroneously
claimed that the long option was indeed called --net; after that commit
long options are not listed at all.

Signed-off-by: Euan Harris <euan.harris@docker.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agocat: fix cat -e and cat -v erroneously numbering 1st line
Denys Vlasenko [Sun, 29 Apr 2018 12:05:43 +0000 (14:05 +0200)]
cat: fix cat -e and cat -v erroneously numbering 1st line

function                                             old     new   delta
cat_main                                             418     421      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoifplugd: close signal race
Denys Vlasenko [Sun, 29 Apr 2018 11:46:49 +0000 (13:46 +0200)]
ifplugd: close signal race

function                                             old     new   delta
ifplugd_main                                        1109    1117      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: do emit the error message on bad input, when we exit with 1
Denys Vlasenko [Tue, 24 Apr 2018 11:49:12 +0000 (13:49 +0200)]
unlzma: do emit the error message on bad input, when we exit with 1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: handle URLs with @ or hash differently
Denys Vlasenko [Tue, 24 Apr 2018 11:35:32 +0000 (13:35 +0200)]
wget: handle URLs with @ or hash differently

If server replied with 302 and

Location: ?foo

we used to underflow the allocated space while trying to form the "@foo"
filename. Switch to forming "foo" filename.

function                                             old     new   delta
packed_usage                                       32795   32799      +4
parse_url                                            387     352     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-35)             Total: -31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agofree: improve --help for type option
Denys Vlasenko [Tue, 24 Apr 2018 08:13:45 +0000 (10:13 +0200)]
free: improve --help for type option

Patch by Fred Friedrich.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoawk: do not allow $(-1)
Denys Vlasenko [Mon, 23 Apr 2018 08:53:18 +0000 (10:53 +0200)]
awk: do not allow $(-1)

function                                             old     new   delta
EMSG_NEGATIVE_FIELD                                    -      25     +25
evaluate                                            3390    3403     +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 38/0)               Total: 38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoexamples/shutdown-1.0: an example of reboot which does not signal init
Denys Vlasenko [Fri, 20 Apr 2018 13:12:52 +0000 (15:12 +0200)]
examples/shutdown-1.0: an example of reboot which does not signal init

For one, my inits know nothing about the concept of "shutting down the system".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: fix another SEGV case
Denys Vlasenko [Thu, 19 Apr 2018 17:29:49 +0000 (19:29 +0200)]
unlzma: fix another SEGV case

function                                             old     new   delta
unpack_lzma_stream                                  1705    1717     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolibbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided
Denys Vlasenko [Tue, 17 Apr 2018 10:43:54 +0000 (12:43 +0200)]
libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided

In practice, "wget http://host.com/" always uses port 80.
People explicitly set non-standard ports via options or parameters
("telnet 1.2.3.4 567" or "telnet 1.2.3.4 ftp") instead of modifying
/etc/services.

function                                             old     new   delta
telnet_main                                         1466    1464      -2
rdate_main                                           215     198     -17
fakeidentd_main                                      269     252     -17
parse_url                                            459     392     -67
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-103)           Total: -103 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agosetlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Denys Vlasenko [Mon, 16 Apr 2018 19:48:32 +0000 (21:48 +0200)]
setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobuild system: FEATURE_NSLOOKUP_BIG needs -lresolv
Denys Vlasenko [Mon, 16 Apr 2018 09:04:03 +0000 (11:04 +0200)]
build system: FEATURE_NSLOOKUP_BIG needs -lresolv

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: fix fallout from "use common routine to set raw termios"
Denys Vlasenko [Mon, 16 Apr 2018 08:24:48 +0000 (10:24 +0200)]
less: fix fallout from "use common routine to set raw termios"

Testcase: (sleep 10; ls) | busybox less

[...]
~           LICENSE
~                  Makefile
~                          Makefile.custom
~                                         Makefile.flags
[...]

less did not want this part:
+ /* dont convert NL to CR+NL on output */
+ newterm->c_oflag &= ~(ONLCR);

function                                             old     new   delta
get_termios_and_make_raw                             108     115      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: simplify make_ptr
Denys Vlasenko [Sun, 15 Apr 2018 18:04:57 +0000 (20:04 +0200)]
nslookup: simplify make_ptr

function                                             old     new   delta
nslookup_main                                       2644    2611     -33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: get rid of query::rlen field
Denys Vlasenko [Sun, 15 Apr 2018 17:51:42 +0000 (19:51 +0200)]
nslookup: get rid of query::rlen field

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoar: stop using static data
Denys Vlasenko [Sun, 15 Apr 2018 12:18:16 +0000 (14:18 +0200)]
ar: stop using static data

function                                             old     new   delta
static.ar_long_names                                   4       -      -4
static.ar_long_name_size                               4       -      -4
get_header_ar                                        546     532     -14
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-22)             Total: -22 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: move array of queries to "globals"
Denys Vlasenko [Sun, 15 Apr 2018 12:10:45 +0000 (14:10 +0200)]
nslookup: move array of queries to "globals"

function                                             old     new   delta
add_query                                             95      89      -6
nslookup_main                                       2692    2641     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-57)             Total: -57 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: remove unnecessary message
Denys Vlasenko [Sun, 15 Apr 2018 11:14:51 +0000 (13:14 +0200)]
less: remove unnecessary message

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoless: implement -F
Aaro Koskinen [Sat, 14 Apr 2018 22:24:24 +0000 (01:24 +0300)]
less: implement -F

Implement -F option: Exit if entire file fits on first screen.

function                                             old     new   delta
buffer_print                                         622     633     +11
less_main                                           2446    2449      +3
buffer_fill_and_print                                169     172      +3
packed_usage                                       32258   32236     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 17/-22)             Total: -5 bytes

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: accept lowercase -type=soa, document query types
Denys Vlasenko [Sun, 15 Apr 2018 10:57:32 +0000 (12:57 +0200)]
nslookup: accept lowercase -type=soa, document query types

    Usage: nslookup [-type=QUERY_TYPE] [-debug] HOST [DNS_SERVER]

    Query DNS about HOST

    QUERY_TYPE: soa,ns,a,aaaa,cname,mx,txt,ptr,any

function                                             old     new   delta
packed_usage                                       32189   32258     +69

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: change -stats to -debug (it's a bug in bind that it accepts -s)
Denys Vlasenko [Sun, 15 Apr 2018 10:49:11 +0000 (12:49 +0200)]
nslookup: change -stats to -debug (it's a bug in bind that it accepts -s)

function                                             old     new   delta
packed_usage                                       32211   32189     -22
nslookup_main                                       2754    2692     -62
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-84)             Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoapplets/install: don't try to install nothing
Yann E. MORIN [Sun, 15 Apr 2018 08:55:30 +0000 (10:55 +0200)]
applets/install: don't try to install nothing

Commit 952d5a6024e7 (applets/install: accept more than one install
option) changed the way we handle install options: before that commit, a
missing install type would mean to install nothing; after, we would
iterate over options, so we would never notice there was a mising
option.

Fix that by introducing an explicit --none option to specify to install
nothing.

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: rework option parsing
Denys Vlasenko [Sun, 15 Apr 2018 10:01:46 +0000 (12:01 +0200)]
nslookup: rework option parsing

function                                             old     new   delta
nslookup_main                                       2715    2754     +39
packed_usage                                       32179   32211     +32
add_ns                                                65      66      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 72/0)               Total: 72 bytes
   text    data     bss     dec     hex filename
 926262     555    5740  932557   e3acd busybox_old
 926239     555    5740  932534   e3ab6 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: smaller qtypes[] array
Denys Vlasenko [Sun, 15 Apr 2018 08:52:11 +0000 (10:52 +0200)]
nslookup: smaller qtypes[] array

function                                             old     new   delta
nslookup_main                                       2708    2715      +7
qtypes                                                80      72      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-8)               Total: -1 bytes
   text    data     bss     dec     hex filename
 926277     555    5740  932572   e3adc busybox_old
 926262     555    5740  932557   e3acd busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: process replies immediately, do not store them
Denys Vlasenko [Sun, 15 Apr 2018 08:46:44 +0000 (10:46 +0200)]
nslookup: process replies immediately, do not store them

function                                             old     new   delta
nslookup_main                                       1837    2708    +871
parse_reply                                          852       -    -852
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 871/-852)           Total: 19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: fix output corruption for "nslookup 1.2.3.4"
Denys Vlasenko [Sat, 14 Apr 2018 21:18:34 +0000 (23:18 +0200)]
nslookup: fix output corruption for "nslookup 1.2.3.4"

function                                             old     new   delta
nslookup_main                                       1832    1837      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: more closely resemble output format of bind-utils-9.11.3
Denys Vlasenko [Sat, 14 Apr 2018 21:08:23 +0000 (23:08 +0200)]
nslookup: more closely resemble output format of bind-utils-9.11.3

function                                             old     new   delta
nslookup_main                                       1880    1832     -48
parse_reply                                         1022     852    -170
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-218)           Total: -218 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: shrink send_queries()
Denys Vlasenko [Sat, 14 Apr 2018 20:53:39 +0000 (22:53 +0200)]
nslookup: shrink send_queries()

function                                             old     new   delta
rcodes                                                68      64      -4
nslookup_main                                       2007    1880    -127
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-131)           Total: -131 bytes
   text    data     bss     dec     hex filename
 926735     555    5740  933030   e3ca6 busybox_old
 926525     555    5740  932820   e3bd4 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: use xmalloc_sockaddr2dotted() instead of homegrown function
Denys Vlasenko [Sat, 14 Apr 2018 16:11:35 +0000 (18:11 +0200)]
nslookup: use xmalloc_sockaddr2dotted() instead of homegrown function

function                                             old     new   delta
nslookup_main                                       2091    2007     -84

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: usee bbox network functions instead of opne-coded mess
Denys Vlasenko [Sat, 14 Apr 2018 15:54:24 +0000 (17:54 +0200)]
nslookup: usee bbox network functions instead of opne-coded mess

function                                             old     new   delta
nslookup_main                                       2363    2091    -272
add_ns                                               663      65    -598
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-870)           Total: -870 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agopatch: implement --dry-run
Denys Vlasenko [Sat, 14 Apr 2018 14:05:26 +0000 (16:05 +0200)]
patch: implement --dry-run

function                                             old     new   delta
static.patch_longopts                                  -     137    +137
patch_main                                          2053    2135     +82
fail_hunk                                            132     139      +7
finish_oldfile                                       119     124      +5
packed_usage                                       32807   32787     -20
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 231/-20)           Total: 211 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: expand: Fix buffer overflow in expandmeta
Denys Vlasenko [Sat, 14 Apr 2018 12:50:47 +0000 (14:50 +0200)]
ash: expand: Fix buffer overflow in expandmeta

Upstream commit:

    Date: Sun, 25 Mar 2018 16:38:00 +0800
    expand: Fix buffer overflow in expandmeta

    The native version of expandmeta allocates a buffer that may be
    overrun for two reasons.  First of all the size is 1 byte too small
    but this is normally hidden because the minimum size is rounded
    up to 2048 bytes.  Secondly, if the directory level is deep enough,
    any buffer can be overrun.

    This patch fixes both problems by calling realloc when necessary.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
function                                             old     new   delta
expmeta                                              517     635    +118
expandarg                                            990     996      +6
mklocal                                              288     290      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 126/0)             Total: 126 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agonslookup: add openwrt / lede version
Denys Vlasenko [Sat, 14 Apr 2018 12:05:45 +0000 (14:05 +0200)]
nslookup: add openwrt / lede version

Needs work on size reduction

function                                             old     new   delta
nslookup_main                                        114    2363   +2249
parse_reply                                            -    1022   +1022
add_ns                                                 -     663    +663
ns_parserr                                             -     486    +486
ns_initparse                                           -     184    +184
ns_skiprr                                              -     117    +117
add_query                                              -      95     +95
qtypes                                                 -      80     +80
rcodes                                                 -      68     +68
dn_skipname                                            -      58     +58
ns_name_uncompress                                     -      56     +56
ns_get16                                               -      13     +13
v4_mapped                                              -      12     +12
ns_get32                                               -       9      +9
res_init                                               3       -      -3
__res_state                                            6       -      -6
xmalloc_sockaddr2hostonly_noport                      10       -     -10
gai_strerror                                          47       -     -47
set_default_dns                                       95       -     -95
print_host                                           199       -    -199
static.res                                           512       -    -512
------------------------------------------------------------------------------
(add/remove: 15/10 grow/shrink: 1/0 up/down: 5112/-872)      Total: 4240 bytes
   text    data     bss     dec     hex filename
 921944     555    6252  928751   e2bef busybox_old
 927375     555    5740  933670   e3f26 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobuild system: fix parallel building issue
Michael Olbrich [Thu, 12 Apr 2018 08:36:54 +0000 (10:36 +0200)]
build system: fix parallel building issue

The files generated by the include/config/MARKER target are in the
dependency list for applets/applet_tables.
If applets/applet_tables is created first during applets_dir then it will
be created again later as part of $(busybox-dirs).
As a result include/applet_tables.h is created again. This time while other
build commands may need it.

Let applets_dir depend on include/config/MARKER to avoid this particular
race condition and create the header files atomically to ensure that the
compiler never sees incomplete files.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotart_stop_daemon: another fix to disabled OLDER_VERSION_OF_X code
Denys Vlasenko [Fri, 13 Apr 2018 23:29:01 +0000 (01:29 +0200)]
tart_stop_daemon: another fix to disabled OLDER_VERSION_OF_X code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agostart_stop_daemon: fix normally disabled OLDER_VERSION_OF_X code
Denys Vlasenko [Fri, 13 Apr 2018 23:23:40 +0000 (01:23 +0200)]
start_stop_daemon: fix normally disabled OLDER_VERSION_OF_X code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agodpkg: fix symlink creation, closes 10941
Denys Vlasenko [Fri, 13 Apr 2018 11:26:33 +0000 (13:26 +0200)]
dpkg: fix symlink creation, closes 10941

function                                             old     new   delta
get_header_ar                                        434     442      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoudhcp: support string user options, closes 10946
Denys Vlasenko [Fri, 13 Apr 2018 11:18:34 +0000 (13:18 +0200)]
udhcp: support string user options, closes 10946

function                                             old     new   delta
udhcp_str2optset                                     536     628     +92
packed_usage                                       32757   32760      +3
udhcpc_main                                         2708    2692     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 95/-16)             Total: 79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoshell: add 6856 $IFS tests to testsuites
Denys Vlasenko [Wed, 11 Apr 2018 18:24:58 +0000 (20:24 +0200)]
shell: add 6856 $IFS tests to testsuites

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix recent breakage from parse_stream() changes
Denys Vlasenko [Wed, 11 Apr 2018 18:00:43 +0000 (20:00 +0200)]
hush: fix recent breakage from parse_stream() changes

function                                             old     new   delta
parse_stream                                        3808    3821     +13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix IFS handling in read
Denys Vlasenko [Wed, 11 Apr 2018 15:18:34 +0000 (17:18 +0200)]
hush: fix IFS handling in read

$ echo "X:Y:" | (IFS=": " read x y; echo "|$x|$y|")
|X|Y|
$ echo "X:Y  :  " | (IFS=": " read x y; echo "|$x|$y|")
|X|Y|

function                                             old     new   delta
shell_builtin_read                                  1320    1426    +106

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: IFS fixes
Denys Vlasenko [Wed, 11 Apr 2018 14:02:58 +0000 (16:02 +0200)]
hush: IFS fixes

$ IFS=": "; x=" "; set x $x; for v; do echo "|$v|"; done
|x|
$ IFS=": "; x=":"; set x $x; for v; do echo "|$v|"; done
|x|
||

function                                             old     new   delta
run_pipe                                            1789    1870     +81
expand_on_ifs                                        310     361     +51
pseudo_exec_argv                                     588     591      +3
builtin_local                                         50      53      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 138/0)             Total: 138 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix "$v" expansion in case patterns when v='[a]'
Denys Vlasenko [Wed, 11 Apr 2018 11:47:59 +0000 (13:47 +0200)]
hush: fix "$v" expansion in case patterns when v='[a]'

function                                             old     new   delta
run_list                                            1053    1063     +10
setup_redirects                                      311     320      +9
encode_then_expand_string                            135     142      +7
run_pipe                                            1784    1789      +5
expand_assignments                                    81      86      +5
expand_string_to_string                              124     125      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 37/0)               Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: parser: Allow newlines within parameter substitution
Denys Vlasenko [Wed, 11 Apr 2018 10:39:18 +0000 (12:39 +0200)]
ash: parser: Allow newlines within parameter substitution

Upstream commit:

Date: Thu, 22 Mar 2018 21:41:24 +0800
parser: Allow newlines within parameter substitution

    On Fri, Mar 16, 2018 at 11:27:22AM +0800, Herbert Xu wrote:
    > On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote:
    > >
    > > Okay, it can be trivially modified to something that does work in other
    > > shells (even if it were actually executed), but gets rejected at parse time
    > > by dash:
    > >
    > >   if false; then
    > >     : ${$+
    > >   }
    > >   fi
    >
    > That's just a bug in dash's parser with ${} in general, because
    > it bombs out without the if clause too:
    >
    >  : ${$+
    >  }

    This patch fixes the parsing of newlines with parameter substitution.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: optimize parse_stream()
Denys Vlasenko [Tue, 10 Apr 2018 23:33:54 +0000 (01:33 +0200)]
hush: optimize parse_stream()

Since we check for '\' anyway when we determine whether we can look ahead,
we can just check for *and handle* it there.

function                                             old     new   delta
parse_stream                                        2751    2740     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: do not drop backslash from eval 'echo ok\'
Denys Vlasenko [Tue, 10 Apr 2018 23:15:33 +0000 (01:15 +0200)]
hush: do not drop backslash from eval 'echo ok\'

newer bash does not drop it, most other shells too

function                                             old     new   delta
unbackslash                                           39      57     +18
parse_stream                                        2753    2751      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-2)              Total: 16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoshell: add comments about [[, no code changes
Denys Vlasenko [Tue, 10 Apr 2018 13:25:41 +0000 (15:25 +0200)]
shell: add comments about [[, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix handling of \<eof> in double-quoted strings
Denys Vlasenko [Tue, 10 Apr 2018 12:49:01 +0000 (14:49 +0200)]
hush: fix handling of \<eof> in double-quoted strings

function                                             old     new   delta
encode_string                                        268     250     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix eval 'echo ok\'
Denys Vlasenko [Tue, 10 Apr 2018 12:40:23 +0000 (14:40 +0200)]
hush: fix eval 'echo ok\'

function                                             old     new   delta
parse_stream                                        2762    2753      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: simplify \<newline> code, part 3
Denys Vlasenko [Tue, 10 Apr 2018 12:20:48 +0000 (14:20 +0200)]
hush: simplify \<newline> code, part 3

function                                             old     new   delta
parse_stream                                        2780    2762     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: simplify \<newline> code, part 2
Denys Vlasenko [Tue, 10 Apr 2018 11:13:10 +0000 (13:13 +0200)]
hush: simplify \<newline> code, part 2

function                                             old     new   delta
parse_stream                                        2787    2780      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: simplify \<newline> code, part 1
Denys Vlasenko [Tue, 10 Apr 2018 11:09:26 +0000 (13:09 +0200)]
hush: simplify \<newline> code, part 1

function                                             old     new   delta
parse_stream                                        2919    2787    -132

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: put "current word" structure into parsing context
Denys Vlasenko [Tue, 10 Apr 2018 01:22:10 +0000 (03:22 +0200)]
hush: put "current word" structure into parsing context

function                                             old     new   delta
done_word                                            790     767     -23
parse_stream                                        3018    2919     -99
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-122)           Total: -122 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: if "[[" bashism is not supported, do not handle it anywhere
Denys Vlasenko [Mon, 9 Apr 2018 23:23:19 +0000 (01:23 +0200)]
ash: if "[[" bashism is not supported, do not handle it anywhere

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agoash: trivial code shrink
Denys Vlasenko [Mon, 9 Apr 2018 23:20:26 +0000 (01:20 +0200)]
ash: trivial code shrink

function                                             old     new   delta
parse_command                                       1677    1674      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotestsuite: allow tests to work in paths containing spaces
Ron Yorston [Fri, 9 Feb 2018 09:52:52 +0000 (09:52 +0000)]
testsuite: allow tests to work in paths containing spaces

Tweak some tests so they work when the path to the test directory or
$HOME contains spaces.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix var_leaks.tests and var_preserved.tests on NOMMU
Denys Vlasenko [Mon, 9 Apr 2018 17:05:11 +0000 (19:05 +0200)]
hush: fix var_leaks.tests and var_preserved.tests on NOMMU

function                                             old     new   delta
remove_nested_vars                                     -      77     +77
run_pipe                                            1756    1786     +30
pseudo_exec_argv                                     376     379      +3
leave_var_nest_level                                  98      32     -66
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 110/-66)            Total: 44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix func_return2.tests on NOMMU
Denys Vlasenko [Mon, 9 Apr 2018 15:54:07 +0000 (17:54 +0200)]
hush: fix func_return2.tests on NOMMU

function                                             old     new   delta
hush_main                                           1714    1718      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agounlzma: fix segfault on bad archive
Denys Vlasenko [Sun, 8 Apr 2018 18:45:16 +0000 (20:45 +0200)]
unlzma: fix segfault on bad archive

function                                             old     new   delta
unpack_lzma_stream                                  2647    2653      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agobzip2: fix two crashes on corrupted archives
Denys Vlasenko [Sun, 8 Apr 2018 18:02:01 +0000 (20:02 +0200)]
bzip2: fix two crashes on corrupted archives

As it turns out, longjmp'ing into freed stack is not healthy...

function                                             old     new   delta
unpack_usage_messages                                  -      97     +97
unpack_bz2_stream                                    369     409     +40
get_next_block                                      1667    1677     +10
get_bits                                             156     155      -1
start_bunzip                                         212     183     -29
bb_show_usage                                        181     120     -61
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/3 up/down: 147/-91)            Total: 56 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agowget: check chunk length for overflowing off_t
Denys Vlasenko [Sun, 8 Apr 2018 16:06:24 +0000 (18:06 +0200)]
wget: check chunk length for overflowing off_t

function                                             old     new   delta
retrieve_file_data                                   428     465     +37
wget_main                                           2386    2389      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0)               Total: 40 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolibbb.h: always include sys/resource.h
Denys Vlasenko [Sun, 8 Apr 2018 15:23:27 +0000 (17:23 +0200)]
libbb.h: always include sys/resource.h

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: remove method checks which are always true/false
Denys Vlasenko [Sun, 8 Apr 2018 14:44:45 +0000 (16:44 +0200)]
lzop: remove method checks which are always true/false

function                                             old     new   delta
do_lzo_compress                                      232     224      -8
lzo_compress                                         531     488     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-51)             Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: buffer several 32-bit writes when we start a new compressed block
Denys Vlasenko [Sun, 8 Apr 2018 14:31:02 +0000 (16:31 +0200)]
lzop: buffer several 32-bit writes when we start a new compressed block

function                                             old     new   delta
lzo_compress                                         483     531     +48

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: reuse strings
Denys Vlasenko [Sun, 8 Apr 2018 12:00:03 +0000 (14:00 +0200)]
lzop: reuse strings

function                                             old     new   delta
lzo_compress                                         470     483     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)               Total: 13 bytes
   text    data     bss     dec     hex filename
 940011     477    7284  947772   e763c busybox_old
 939976     477    7284  947737   e7619 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: checksum reads do not need to be checksummed
Denys Vlasenko [Sun, 8 Apr 2018 11:45:04 +0000 (13:45 +0200)]
lzop: checksum reads do not need to be checksummed

function                                             old     new   delta
do_lzo_decompress                                    404     427     +23
f_read32                                              22       -     -22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: don't support ancient versions < 0.94 (15 Oct 1997)
Denys Vlasenko [Sun, 8 Apr 2018 11:35:28 +0000 (13:35 +0200)]
lzop: don't support ancient versions < 0.94 (15 Oct 1997)

0.94 came only 2 months after initial 0.90:

    0.90 (10 Aug 1997): First public release of lzop
    ...
    0.94 (15 Oct 1997): Header format change

function                                             old     new   delta
do_lzo_decompress                                    411     404      -7
f_read8                                               24       -     -24
f_read16                                              31       -     -31
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-62)             Total: -62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agolzop: code shrink by using header_t matching on-disk layout
Denys Vlasenko [Sun, 8 Apr 2018 11:32:47 +0000 (13:32 +0200)]
lzop: code shrink by using header_t matching on-disk layout

function                                             old     new   delta
add_bytes_to_chksum                                   37      47     +10
lzo_decompress                                       524     532      +8
init_chksum                                           14      21      +7
chksum_getresult                                      13      17      +4
f_read                                                33      28      -5
f_write8                                              20       -     -20
f_write32                                             22       -     -22
f_write16                                             25       -     -25
f_write                                               36       -     -36
do_lzo_compress                                      328     232     -96
do_lzo_decompress                                    526     411    -115
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 4/3 up/down: 29/-319)          Total: -290 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agotar: trim help text
Denys Vlasenko [Sat, 7 Apr 2018 19:04:39 +0000 (21:04 +0200)]
tar: trim help text

Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [--exclude PATTERN]... [FILE]...

Create, extract, or list files from a tar file

Operation:  <============== DELETED
    c Create
    x Extract
    t List
    -f FILE Name of TARFILE ('-' for stdin/out)
    -C DIR Change to DIR before operation
    -v Verbose
    -O Extract to stdout
    -m Don't restore mtime
    -o Don't restore user:group
    -k Don't replace existing files
    -Z (De)compress using compress
    -z (De)compress using gzip
    -J (De)compress using xz
    -j (De)compress using bzip2
    -a (De)compress using lzma
    -h Follow symlinks
    -T FILE File with names to include
    -X FILE File with glob patterns to exclude
    --exclude PATTERN Glob pattern to exclude

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 years agohush: fix prompt in multi-line $(())
Denys Vlasenko [Sat, 7 Apr 2018 15:01:31 +0000 (17:01 +0200)]
hush: fix prompt in multi-line $(())

Now shows PS2 in this case:

/path/to/dir $ a=b; echo $((
> _

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