oweals/busybox.git
7 years agotls: avoid using int16 in pstm code
Denys Vlasenko [Mon, 3 Apr 2017 19:53:29 +0000 (21:53 +0200)]
tls: avoid using int16 in pstm code

function                                             old     new   delta
pstm_div                                            1472    1522     +50
psRsaEncryptPub                                      403     413     +10
pstm_2expt                                            91      96      +5
pstm_clear                                            68      72      +4
pstm_init                                             39      42      +3
pstm_unsigned_bin_size                                36      37      +1
pstm_montgomery_reduce                               398     399      +1
pstm_init_size                                        45      46      +1
pstm_zero                                             39      38      -1
pstm_set                                              35      34      -1
pstm_read_unsigned_bin                               112     109      -3
pstm_mulmod                                          123     120      -3
pstm_mod                                             116     113      -3
pstm_cmp                                              57      54      -3
pstm_sub                                             107     102      -5
pstm_to_unsigned_bin                                 157     151      -6
pstm_clamp                                            63      57      -6
pstm_add                                             116     108      -8
pstm_grow                                             81      72      -9
pstm_count_bits                                       57      48      -9
pstm_init_copy                                        84      72     -12
pstm_cmp_mag                                          93      78     -15
pstm_sqr_comba                                       567     551     -16
pstm_montgomery_calc_normalization                   158     140     -18
pstm_copy                                            115      92     -23
pstm_lshd                                            133     109     -24
pstm_mul_comba                                       525     500     -25
pstm_mul_d                                           251     224     -27
s_pstm_sub                                           256     228     -28
s_pstm_add                                           370     337     -33
pstm_div_2d                                          444     409     -35
pstm_mul_2                                           195     156     -39
pstm_rshd                                            154     104     -50
pstm_mul_2d                                          247     186     -61
pstm_exptmod                                        1524    1463     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/27 up/down: 75/-524)         Total: -449 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: merge sha1 and sha256 hmac functions
Denys Vlasenko [Mon, 3 Apr 2017 15:43:44 +0000 (17:43 +0200)]
tls: merge sha1 and sha256 hmac functions

function                                             old     new   delta
hmac_begin                                             -     196    +196
hmac_sha256                                           61      68      +7
hmac                                                 250      87    -163
hmac_sha256_begin                                    190       -    -190
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 203/-353)         Total: -150 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: replace aes encryption/decryption by much smaller one
Denys Vlasenko [Sat, 1 Apr 2017 18:11:59 +0000 (20:11 +0200)]
tls: replace aes encryption/decryption by much smaller one

The replacement code is ~6 times slower,
but drastically decreases size of tls_aes.o:

text data bss dec hex filename
8050 0 0 8050 1f72 tls_aes_OLD.o
2461 0 0 2461 99d tls_aes.o

function                                             old     new   delta
sbox                                                   -     256    +256
rsbox                                                  -     256    +256
KeyExpansion                                           -     197    +197
Subword                                                -      66     +66
AddRoundKey                                            -      61     +61
static.Rcon                                            -      10     +10
rcon                                                  40       -     -40
setup_mix                                             80       -     -80
setup_mix2                                           123       -    -123
aes_cbc_decrypt                                     1377     971    -406
aes_cbc_encrypt                                     1375     644    -731
psAesInit                                            848       -    -848
Te4                                                 1024       -   -1024
TE0                                                 1024       -   -1024
TD0                                                 1024       -   -1024
Td4                                                 1040       -   -1040
------------------------------------------------------------------------------
(add/remove: 6/8 grow/shrink: 0/2 up/down: 846/-6340)       Total: -5494 bytes

This code is based on public domain "tiny-AES128-C" code.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agouniq: add -i option to ignore case
Jody Bruchon [Thu, 30 Mar 2017 16:15:54 +0000 (18:15 +0200)]
uniq: add -i option to ignore case

Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoUpdate depmod & modprobe upstream help text in comments
Kang-Che Sung [Thu, 9 Feb 2017 14:48:51 +0000 (22:48 +0800)]
Update depmod & modprobe upstream help text in comments

No code changes.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp6: move misplaced comment
Denys Vlasenko [Mon, 27 Mar 2017 20:49:12 +0000 (22:49 +0200)]
udhcp6: move misplaced comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp6: fix releasing
Denys Vlasenko [Mon, 27 Mar 2017 20:32:44 +0000 (22:32 +0200)]
udhcp6: fix releasing

Patch is based on work by tiggerswelt.net. They say:
"
We wanted udhcpc6 to release its IPv6-Addresses on
quit (-R-commandline-option) which turned out to generate once again
kind of garbage on the network-link.
We tracked this down to two issues:

 - udhcpc6 uses a variable called "srv6_buf" to send packets to
   the dhcp6-server, but this variable is never initialized correctly
   and contained kind of a garbage-address

 - The address of the dhcp6-server is usually a link-local-address,
   that requires an interface-index when using connect() on an AF_INET6-
   socket

We added an
additional parameter for ifindex to d6_send_kernel_packet() and made
d6_recv_raw_packet() to capture the address of the dhcp6-server and
forward it to its callee.
"

Three last patches together:

function                                             old     new   delta
d6_read_interface                                      -     454    +454
d6_recv_raw_packet                                     -     283    +283
option_to_env                                        249     504    +255
.rodata                                           165226  165371    +145
send_d6_discover                                     195     237     +42
send_d6_select                                       118     159     +41
send_d6_renew                                        173     186     +13
send_d6_release                                      162     173     +11
opt_req                                                -      10     +10
d6_send_kernel_packet                                304     312      +8
opt_fqdn_req                                           -       6      +6
d6_mcast_from_client_config_ifindex                   48      51      +3
d6_find_option                                        63      61      -2
udhcpc6_main                                        2416    2411      -5
static.d6_recv_raw_packet                            266       -    -266
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/2 up/down: 1271/-273)         Total: 998 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp6: fix problems found running against dnsmasq
Denys Vlasenko [Mon, 27 Mar 2017 20:22:09 +0000 (22:22 +0200)]
udhcp6: fix problems found running against dnsmasq

Patch is based on work by tiggerswelt.net. They say:
"
But when we tried to use dnsmasq on server-side, udhcpc6 was unable to
forward the acquired address to its setup-script although the
IPv6-Address had been assigned by the server as we could see via
tcpdump. We traced this issue down to a problem on how udhcpc6 parses
DHCPv6-Options: When moving to next option, a pointer-address is
increased and a length buffer is decreased by the length of the option.
The problem is that it is done in this order:

  option += 4 + option[3];
  len_m4 -= 4 + option[3];

But this has to be switched as the length is decreased by the length of
the *next* option, not the current one. This affected both - internal
checks if a required option is present and the function to expose
options to the environment of the setup-script.
There was also a bug parsing D6_OPT_STATUS_CODE Options, that made
dnsmasq not work as udhcpc6 thought it is receiving a non-positive
status-code (because it did not parse the status-code as required in RFC
3315).
In addition we introduced basic support for RFC 3646 (OPTION_DNS_SERVERS
and OPTION_DOMAIN_LIST) and RFC 4704 (OPTION_CLIENT_FQDN).
"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp6: read_interface should save link-local ipv6 address
Denys Vlasenko [Mon, 27 Mar 2017 20:10:15 +0000 (22:10 +0200)]
udhcp6: read_interface should save link-local ipv6 address

Patch is based on work by tiggerswelt.net. They say:
"Using this patch it was no problem to acquire an IPv6-Address via DHCPv6
using ISC DHCPD6 on server-side."

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agovi: avoid touching a new file with ZZ when no editing has been done
Yousong Zhou [Fri, 24 Mar 2017 20:13:10 +0000 (21:13 +0100)]
vi: avoid touching a new file with ZZ when no editing has been done

This is the behaviour observed with standard vim and busybox vi of at
least 1.22.1.  It was changed with commit "32afd3a vi: some
simplifications" which happened before 1.23.0.

Mistyping filename on command line happens fairly often and it's better
we restore the old behaviour to avoid a few unnecessary flash writes and
sometimes efforts of debugging bugs caused by those unneeded stray
files.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoswitch_root: don't bail out when console doesn't exist
Andrei Gherzan [Fri, 24 Mar 2017 15:39:08 +0000 (16:39 +0100)]
switch_root: don't bail out when console doesn't exist

Busybox is very often used in initramfs at the end of which usually
there is a switch_root to the actual rootfs. There are many cases where
the console kernel argument is either just a placeholder (for example
RaspberryPi uses serial0 and serial1) or configured as null to avoid any
console messages - usually you would see such of a setup in production
environments.

Currently busybox bails out if can't open the console argument. If this
happenes in initramfs and if the console=null for example, you get in a
blind kernel panic. Avoid this by only warning instead of dying.

function                                             old     new   delta
switch_root_main                                     371     368      -3

Signed-off-by: Andrei Gherzan <andrei@gherzan.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agowhitespace fix
Denys Vlasenko [Fri, 24 Mar 2017 14:00:12 +0000 (15:00 +0100)]
whitespace fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agopaste: delimiter list use should restart for each new output line
Denys Vlasenko [Thu, 23 Mar 2017 16:58:32 +0000 (17:58 +0100)]
paste: delimiter list use should restart for each new output line

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotypo fix
Denys Vlasenko [Thu, 23 Mar 2017 16:41:59 +0000 (17:41 +0100)]
typo fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agopaste: new applet
Maxime Coste [Thu, 23 Mar 2017 16:35:20 +0000 (17:35 +0100)]
paste: new applet

function                                             old     new   delta
paste_main                                             -     493    +493
packed_usage                                       31019   31070     +51
applet_names                                        2569    2575      +6
applet_main                                         1484    1488      +4
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/0 up/down: 554/0)             Total: 554 bytes

Signed-off-by: Maxime Coste <mawww@kakoune.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agodd: call fsync() only once before exiting if conv=fsync is specified
Rostislav Skudnov [Thu, 16 Mar 2017 19:54:35 +0000 (20:54 +0100)]
dd: call fsync() only once before exiting if conv=fsync is specified

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoRevert "umount: make -d always active, add -D to suppress it"
Denys Vlasenko [Thu, 16 Mar 2017 16:45:07 +0000 (17:45 +0100)]
Revert "umount: make -d always active, add -D to suppress it"

This reverts commit 86a03bee1d3d6990c03bf500836b19ec8a1c1f12.

Since now our "mount -oloop" creates AUTOCLEARed loopdevs, we no longer
need our umount to destroy loopdevs to match the usual util-linux behaviour.

Now this revert fixes another, opposite bug: "explicit" mount /dev/loopN
and then umount must not drop loopdevs!

User complaint is as follows:

It seems LOOP_CLR_FD called on a loop-*partition* removes the mapping of
the whole *device* - which results in the following:

root@LEDE:/# loop=$(losetup -f)
root@LEDE:/# echo ${loop}
/dev/loop2
root@LEDE:/# losetup ${loop} /IMAGE
root@LEDE:/# ls -l ${loop}*
brw-------  1 root root     7,   2 Mar  6 20:09 /dev/loop2
root@LEDE:/# partprobe ${loop}
root@LEDE:/# ls -l ${loop}*
brw-------  1 root  root    7,   2 Mar  6 20:09 /dev/loop2
brw-------  1 root  root  259,   8 Mar  6 21:59 /dev/loop2p1
brw-------  1 root  root  259,   9 Mar  6 21:59 /dev/loop2p2
brw-------  1 root  root  259,  10 Mar  6 21:59 /dev/loop2p3
brw-------  1 root  root  259,  11 Mar  6 21:59 /dev/loop2p4
brw-------  1 root  root  259,  12 Mar  6 21:59 /dev/loop2p5
brw-------  1 root  root  259,  13 Mar  6 21:59 /dev/loop2p6
brw-------  1 root  root  259,  14 Mar  6 21:59 /dev/loop2p7
brw-------  1 root  root  259,  15 Mar  6 21:59 /dev/loop2p8
root@LEDE:/# mount ${loop}p8 /MOUNT       # mount loop partition
root@LEDE:/# losetup -a | grep $loop      # loop dev mapping still there
/dev/loop2: 0 /mnt/IMAGE
root@LEDE:/# strace umount /MOUNT 2> /log # unmount loop partition
root@LEDE:/# losetup -a | grep ${loop}    # loop device mapping is gone
root@LEDE:/# grep -i loop /log
open("/dev/loop2p7", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, LOOP_CLR_FD)                   = 0
root@LEDE:/#

The strace was done to figure out, if maybe umount wrongly ioctl()'s the
parent device instead of the partition - it doesn't.

I already wasn't a fan of umount implicitly removing the mapping in the
first place (as I usually setup and release loop devices with `losetup`
and scripts needed to call umount differently in order to work and
outside busybox).

However taking above (kernel-)behaviour into account - umount calling
ioctl(LOOP_CLR_FD) unconditionally potentially causes some nasty side
effects

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomount: create loop devices with LO_FLAGS_AUTOCLEAR flag
Denys Vlasenko [Thu, 16 Mar 2017 15:49:37 +0000 (16:49 +0100)]
mount: create loop devices with LO_FLAGS_AUTOCLEAR flag

The "autolooped" mount (mount [-oloop] IMAGE /DIR/DIR)
always creates AUTOCLEARed loopdevs, so that umounting
drops them (and this does not require any code in the
umount userspace).
This happens since circa linux-2.6.25:
commit 96c5865559cee0f9cbc5173f3c949f6ce3525581
Date:    Wed Feb 6 01:36:27 2008 -0800
Subject: Allow auto-destruction of loop devices
IOW: in this case, umount does not have to use -d
to drop the loopdev.

The explicit loop mount (mount /dev/loopN /DIR/DIR)
does not do this. In this case, umount without -d
should not drop loopdev.
Unfortunately, bbox umount currently always implies -d,
this probably needs fixing.

function                                             old     new   delta
set_loop                                             537     597     +60
singlemount                                         1101    1138     +37
losetup_main                                         419     432     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 110/0)             Total: 110 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agorunit: fix chpst -n -N -u USER
Denys Vlasenko [Mon, 13 Mar 2017 21:32:05 +0000 (22:32 +0100)]
runit: fix chpst -n -N -u USER

busybox's chpst first switches user/group and then tries to call nice().
Once the root priviledges are dropped, process priority can only be lowered.
So negative nice values don't work anymore.
Upstream version of chpst correctly calls nice() before switching user.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agovi: don't touch file with :x when modified_count == 0
Denys Vlasenko [Mon, 13 Mar 2017 19:50:42 +0000 (20:50 +0100)]
vi: don't touch file with :x when modified_count == 0

Along with it, there are other changes

 - Check for uppercase X is removed as the expression will be always false and
   :X itself is another totally different command in standard vim
 - The status line will show number of written lines instead of lines requested
   by the colon command.  This is also how the standard vim is doing, though
   the difference is that '!' has to be explicitly specified in vim to allow
   partial writes

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoreset: before calling execvp(), reset needs to flush stdout
Glenn Matthews [Fri, 17 Feb 2017 22:01:13 +0000 (23:01 +0100)]
reset: before calling execvp(), reset needs to flush stdout

Signed-off-by: Glenn Matthews <glmatthe@cisco.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoFix FEATURE_{GZIP,BZIP2}_DECOMPRESS link error
Kang-Che Sung [Fri, 17 Feb 2017 11:04:24 +0000 (19:04 +0800)]
Fix FEATURE_{GZIP,BZIP2}_DECOMPRESS link error

... when gzip is selected but not gunzip nor zcat, or when bzip2 is
selected but not bunzip2 nor bzcat.

This regression is introduced in b130f9f758b6404c6d0911a1c120937ae6ab47f8
("Allow 'gzip -d' and 'bzip2 -d' without gunzip or bunzip2")

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcpc: make sure we do not overflow poll timeout
Denys Vlasenko [Fri, 17 Feb 2017 18:20:32 +0000 (19:20 +0100)]
udhcpc: make sure we do not overflow poll timeout

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agonc_bloaty: use poll() instead of select()
Denys Vlasenko [Fri, 17 Feb 2017 16:48:59 +0000 (17:48 +0100)]
nc_bloaty: use poll() instead of select()

function                                             old     new   delta
readwrite                                            829     715    -114

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp: use poll() instead of select()
Denys Vlasenko [Thu, 16 Feb 2017 22:25:44 +0000 (23:25 +0100)]
udhcp: use poll() instead of select()

function                                             old     new   delta
udhcp_sp_read                                         65      46     -19
udhcp_sp_fd_set                                       79      54     -25
udhcpd_main                                         1530    1482     -48
udhcpc_main                                         2780    2730     -50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-142)           Total: -142 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoudhcp: do not clobber errno by signal handler
Denys Vlasenko [Thu, 16 Feb 2017 19:04:19 +0000 (20:04 +0100)]
udhcp: do not clobber errno by signal handler

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agonc: use poll() instead of select()
Denys Vlasenko [Thu, 16 Feb 2017 16:17:17 +0000 (17:17 +0100)]
nc: use poll() instead of select()

function                                             old     new   delta
nc_main                                              943     866     -77

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: covert i/o loop from using select() to poll()
Denys Vlasenko [Thu, 16 Feb 2017 15:27:39 +0000 (16:27 +0100)]
tls: covert i/o loop from using select() to poll()

function                                             old     new   delta
tls_run_copy_loop                                    377     282     -95

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agosendmail: allow "+" symbol in recipient. Closes 9646
Denys Vlasenko [Sun, 12 Feb 2017 20:57:22 +0000 (21:57 +0100)]
sendmail: allow "+" symbol in recipient. Closes 9646

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: define and use DEPMOD_OPT_n (option mask)
Kang-Che Sung [Thu, 9 Feb 2017 14:48:52 +0000 (22:48 +0800)]
modprobe-small: define and use DEPMOD_OPT_n (option mask)

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: document '-n' in depmod usage
Kang-Che Sung [Thu, 9 Feb 2017 14:48:50 +0000 (22:48 +0800)]
modprobe-small: document '-n' in depmod usage

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe_small: if only MODPROBE and DEPMOD are selected, no need to test for them
Denys Vlasenko [Tue, 7 Feb 2017 15:41:25 +0000 (16:41 +0100)]
modprobe_small: if only MODPROBE and DEPMOD are selected, no need to test for them

function                                             old     new   delta
modprobe_main                                        321     306     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoReorder modutils config options & fix yet more dependency
Kang-Che Sung [Wed, 1 Feb 2017 11:43:54 +0000 (19:43 +0800)]
Reorder modutils config options & fix yet more dependency

- modprobe can indirectly benefit from FEATURE_2_4_MODULES and
  FEATURE_INSMOD_TRY_MAP options.
- The position of config FEATURE_INSMOD_TRY_MMAP prevented some other
  config options from indenting under FEATURE_2_4_MODULES. Reorder to
  fix this.
- FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is now moved to
  Config.src under "Common options" section. (I wished to edit this
  config so that it also work with "big" modutils, but it's not done at
  the moment. Sorry.)

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodutils: fix config options dependency (2)
Kang-Che Sung [Sun, 5 Feb 2017 18:02:34 +0000 (19:02 +0100)]
modutils: fix config options dependency (2)

- The modprobe-small implementation of rmmod no longer chdir's to
  "/lib/modules/`uname -r`" as it was not necessary for rmmod's
  operation. (And it no longer need to die if such modules directory
  doesn't exist.)
- Configs DEFAULT_MODULES_DIR and DEFAULT_DEPMOD_FILE no longer depend
  on MODPROBE_SMALL as the latter may not enable depmod or modprobe
  that requires these configs.
- Clarify DEFAULT_DEPMOD_FILE's description regarding the ".bb" name
  suffix.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohttpd: use "Content-Length", not "-length"
Denys Vlasenko [Sat, 4 Feb 2017 22:19:30 +0000 (23:19 +0100)]
httpd: use "Content-Length", not "-length"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoReplace int -> uint to avoid signed integer overflow
Rostislav Skudnov [Wed, 1 Feb 2017 18:35:13 +0000 (18:35 +0000)]
Replace int -> uint to avoid signed integer overflow

An example of such an error (should be compiled with DEBUG_SANITIZE):

runtime error: left shift of 1 by 31 places cannot be represented in
type 'int'

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: fold AES CBC en/decryption into single functions
Denys Vlasenko [Sat, 4 Feb 2017 15:23:49 +0000 (16:23 +0100)]
tls: fold AES CBC en/decryption into single functions

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agowget/tls: session_id of zero length is ok (arxiv.org responds with such)
Denys Vlasenko [Fri, 3 Feb 2017 17:19:59 +0000 (18:19 +0100)]
wget/tls: session_id of zero length is ok (arxiv.org responds with such)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: add INT_OFF/ON around allocations
Denys Vlasenko [Fri, 3 Feb 2017 12:00:06 +0000 (13:00 +0100)]
ash: add INT_OFF/ON around allocations

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agops: avoid -o stat to contain spaces. Closes 9631
Denys Vlasenko [Thu, 2 Feb 2017 12:04:30 +0000 (13:04 +0100)]
ps: avoid -o stat to contain spaces. Closes 9631

function                                             old     new   delta
procps_scan                                         1227    1236      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agocmdline module options can be disabled on "big" modutils
Kang-Che Sung [Tue, 31 Jan 2017 13:09:17 +0000 (21:09 +0800)]
cmdline module options can be disabled on "big" modutils

Allow module options on command line to be disabled on "big" modutils.

Config FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is renamed to
FEATURE_CMDLINE_MODULE_OPTIONS and no longer depends on !MODPROBE_SMALL

(I'm not sure if disabling this is useful on "big" modutils, but at
least the macro can serve as a marker and ensure both implementations
of same feature have consistent behavior.)

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodutils: remove redundant "select PLATFORM_LINUX" configs
Kang-Che Sung [Wed, 1 Feb 2017 00:43:32 +0000 (01:43 +0100)]
modutils: remove redundant "select PLATFORM_LINUX" configs

It is enough to have only applets' configs select PLATFORM_LINUX.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: move lsmod code out of modprobe_main()
Kang-Che Sung [Tue, 31 Jan 2017 09:06:43 +0000 (17:06 +0800)]
modprobe-small: move lsmod code out of modprobe_main()

Having lsmod code inside modprobe_main() makes some of the applet name
checking code awkward. Besides, this make busybox x86_64 binary a few
bytes smaller. :)

function                                  old     new   delta
lsmod_main                                  -      23     +23
modprobe_main                             599     564     -35
-------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 23/-35) Total: -12 bytes

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: improve config help text
Denys Vlasenko [Wed, 1 Feb 2017 00:22:37 +0000 (01:22 +0100)]
modprobe-small: improve config help text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoash: improve / fix glob expansion
Felix Fietkau [Tue, 31 Jan 2017 20:58:55 +0000 (21:58 +0100)]
ash: improve / fix glob expansion

When using musl libc glob() a very long string can cause glob() to fail,
which leads to an out of memory error being raised by ash.

This can happen easily if a very long quoted string contains *, even
though no glob expansion should ever be performed on it (since it's
quoted).

Fix this by properly parsing control characters and escaping and only
accept unquoted metacharacters. While we're at it, unify this check for
libc and built-in glob expansion

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotaskset: simplify code a bit; tweak --help
Denys Vlasenko [Mon, 30 Jan 2017 21:20:06 +0000 (22:20 +0100)]
taskset: simplify code a bit; tweak --help

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodprobe-small: fix --help texts, they are from "big" modutils
Denys Vlasenko [Mon, 30 Jan 2017 18:21:12 +0000 (19:21 +0100)]
modprobe-small: fix --help texts, they are from "big" modutils

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomodutils: fix config options dependency
Kang-Che Sung [Mon, 30 Jan 2017 18:14:50 +0000 (19:14 +0100)]
modutils: fix config options dependency

module.aliases and module.symbols files have no use in modprobe-small
implementation. So FEATURE_MODUTILS_ALIAS and FEATURE_MODUTILS_SYMBOLS
will depend on !MODPROBE_SMALL.

The try_to_mmap_module() function is not called in modprobe-small.c,
so I will let FEATURE_INSMOD_TRY_MMAP depend on !MODPROBE_SMALL for
now.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Likewise, FEATURE_2_4_MODULES is not used by modprobe-small.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agowget: add a big explanation what TLS code implements and what does not
Denys Vlasenko [Mon, 30 Jan 2017 15:27:37 +0000 (16:27 +0100)]
wget: add a big explanation what TLS code implements and what does not

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: match_fstype() is unreadable in the extreme, fixing it
Denys Vlasenko [Sun, 29 Jan 2017 23:45:05 +0000 (00:45 +0100)]
libbb: match_fstype() is unreadable in the extreme, fixing it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agovi,fsck: do not use build timestamp unconditionally. Closes 9626
Denys Vlasenko [Sun, 29 Jan 2017 18:14:26 +0000 (19:14 +0100)]
vi,fsck: do not use build timestamp unconditionally. Closes 9626

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotaskset: separate "current" and "new" strings
Denys Vlasenko [Sun, 29 Jan 2017 17:59:38 +0000 (18:59 +0100)]
taskset: separate "current" and "new" strings

Better for constant sharing:

   text    data     bss     dec     hex filename
 912997     485    6856  920338   e0b12 busybox_old
 912988     485    6856  920329   e0b09 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotypo in comment
Denys Vlasenko [Sun, 29 Jan 2017 17:48:58 +0000 (18:48 +0100)]
typo in comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotaskset: rewrite to be task size-agnostic
Denys Vlasenko [Sun, 29 Jan 2017 17:19:29 +0000 (18:19 +0100)]
taskset: rewrite to be task size-agnostic

function                                             old     new   delta
packed_usage                                       31130   31190     +60
taskset_main                                         623     525     -98
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 60/-98)            Total: -38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years ago*: add comment about APPLET_ODDNAME format
Denys Vlasenko [Sun, 29 Jan 2017 13:57:33 +0000 (14:57 +0100)]
*: add comment about APPLET_ODDNAME format

It confused me more than once

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohttpd: defend against attempts to OOM us. Closes 9611
Denys Vlasenko [Thu, 26 Jan 2017 18:35:40 +0000 (19:35 +0100)]
httpd: defend against attempts to OOM us. Closes 9611

We were strdup'ing "Cookie: foo" every time we saw it.

function                                             old     new   delta
handle_incoming_and_exit                            2733    2821     +88

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoadduser: help for -G GRP is misleading, fix it
Denys Vlasenko [Thu, 26 Jan 2017 17:54:12 +0000 (18:54 +0100)]
adduser: help for -G GRP is misleading, fix it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agosh: fix FEATURE_SH_STANDALONE help text: it does not enable NOFORK
Denys Vlasenko [Thu, 26 Jan 2017 17:31:51 +0000 (18:31 +0100)]
sh: fix FEATURE_SH_STANDALONE help text: it does not enable NOFORK

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: spawn_and_wait() fflushes before forking NOEXEC; child reinits logmode
Denys Vlasenko [Thu, 26 Jan 2017 00:13:58 +0000 (01:13 +0100)]
libbb: spawn_and_wait() fflushes before forking NOEXEC; child reinits logmode

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolink: new applet
Denys Vlasenko [Wed, 25 Jan 2017 23:27:53 +0000 (00:27 +0100)]
link: new applet

coreutils grew itself a tiny simplistic alternative to ln:

Usage: link FILE LINK

Create hard LINK to FILE

function                                             old     new   delta
link_main                                              -      75     +75
packed_usage                                       31114   31131     +17
applet_names                                        2564    2569      +5
applet_main                                         1480    1484      +4
applet_install_loc                                   185     186      +1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 102/0)             Total: 102 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoxxd: make -p output lines actually end with a newline
Denys Vlasenko [Wed, 25 Jan 2017 16:00:38 +0000 (17:00 +0100)]
xxd: make -p output lines actually end with a newline

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoxxd: implement -p
Denys Vlasenko [Wed, 25 Jan 2017 15:50:30 +0000 (16:50 +0100)]
xxd: implement -p

While at it, tweaked hexdump --help

function                                             old     new   delta
xxd_main                                             364     414     +50
packed_usage                                       31097   31114     +17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agolibbb: shrink sump.c
Denys Vlasenko [Wed, 25 Jan 2017 15:21:00 +0000 (16:21 +0100)]
libbb: shrink sump.c

function                                             old     new   delta
dot_flags_width_chars                                  -      16     +16
int_convs                                              -       7      +7
lcc                                                    7       -      -7
index_str                                             16       -     -16
rewrite                                             1013     937     -76
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 23/-99)            Total: -76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoftpd/ls: show directories first
Denys Vlasenko [Wed, 25 Jan 2017 03:52:45 +0000 (04:52 +0100)]
ftpd/ls: show directories first

Old TODO finally done

function                                             old     new   delta
ls_main                                              548     568     +20
packed_usage                                       31116   31097     -19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agohexdump/xxd: a bit more condensed formats
Denys Vlasenko [Wed, 25 Jan 2017 02:07:39 +0000 (03:07 +0100)]
hexdump/xxd: a bit more condensed formats

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoxxd: new applet
Denys Vlasenko [Wed, 25 Jan 2017 00:58:00 +0000 (01:58 +0100)]
xxd: new applet

Yet Another Hexdumper

function                                             old     new   delta
xxd_main                                               -     364    +364
packed_usage                                       31046   31116     +70
applet_names                                        2560    2564      +4
applet_main                                         1476    1480      +4
rewrite                                             1022    1013      -9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 442/-9)            Total: 433 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoftpd: new option -a ANON_USER to allow anonymous logins
Andrey Mozzhuhin [Tue, 24 Jan 2017 22:02:04 +0000 (23:02 +0100)]
ftpd: new option -a ANON_USER to allow anonymous logins

Anonymous ftpd login is useful even when ftpd authentication feature
is enabled. Anonymous logins provide simple password-less connection
for FTP clients.

To allow password-less connection user command line option '-a USER' is
added. This option specifies the system user to use when
'anonymous' username is given in USER command. No password is required
in this case.

function                                             old     new   delta
ftpd_main                                           2164    2232     +68
packed_usage                                       31015   31046     +31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 99/0)               Total: 99 bytes

Signed-off-by: Andrey Mozzhuhin <amozzhuhin@yandex.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agowget: add support for -S --server-response
Denys Vlasenko [Tue, 24 Jan 2017 20:41:43 +0000 (21:41 +0100)]
wget: add support for -S --server-response

Based on the patch by stephane.billiart@gmail.com

function                                             old     new   delta
ftpcmd                                                87     129     +42
fgets_and_trim                                        86     119     +33
static.wget_longopts                                 234     252     +18
packed_usage                                       31002   31015     +13
wget_main                                           2535    2540      +5
gethdr                                               158     163      +5
retrieve_file_data                                   424     428      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 120/0)             Total: 120 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoremove "local" bashism from a few scripts
Denys Vlasenko [Tue, 24 Jan 2017 19:52:42 +0000 (20:52 +0100)]
remove "local" bashism from a few scripts

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: can download kernels now :)
Denys Vlasenko [Tue, 24 Jan 2017 17:08:07 +0000 (18:08 +0100)]
tls: can download kernels now :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: if got CERTIFICATE_REQUEST, send an empty CERTIFICATE
Denys Vlasenko [Tue, 24 Jan 2017 16:06:10 +0000 (17:06 +0100)]
tls: if got CERTIFICATE_REQUEST, send an empty CERTIFICATE

wolfssl test server is not satisfied by an empty one,
but some real servers might be.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work
Denys Vlasenko [Tue, 24 Jan 2017 15:00:54 +0000 (16:00 +0100)]
tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work

Good news that TLS_RSA_WITH_AES_256_CBC_SHA256 still works with new code ;)

This change adds inevitable extension to have different sized hashes and AES key sizes.
In libbb, md5_end() and shaX_end() are extended to return result size instead of void -
this helps *a lot* in tls (the cost is ~5 bytes per _end() function).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: convert DISP_DIRNAME to a bool variable
Denys Vlasenko [Mon, 23 Jan 2017 19:46:12 +0000 (20:46 +0100)]
ls: convert DISP_DIRNAME to a bool variable

function                                             old     new   delta
ls_main                                              553     548      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: get rid of opt_flags[], handle -l1c through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 19:43:06 +0000 (20:43 +0100)]
ls: get rid of opt_flags[], handle -l1c through option_mask32

function                                             old     new   delta
display_single                                       885     888      +3
scan_and_display_dirs_recur                          496     486     -10
opt_flags                                             11       -     -11
ls_main                                              618     553     -65
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 3/-86)             Total: -83 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -x through option_mask32, remove default -C from --help
Denys Vlasenko [Mon, 23 Jan 2017 19:21:14 +0000 (20:21 +0100)]
ls: handle -x through option_mask32, remove default -C from --help

function                                             old     new   delta
packed_usage                                       31024   31002     -22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -d and -R through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 19:08:22 +0000 (20:08 +0100)]
ls: handle -d and -R through option_mask32

function                                             old     new   delta
scan_and_display_dirs_recur                          545     550      +5
display_single                                      1039    1044      +5
append_char                                           67      68      +1
display_files                                        399     396      -3
ls_main                                              736     717     -19
opt_flags                                             68      11     -57
.rodata                                           168864  168784     -80
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/4 up/down: 11/-159)          Total: -148 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -p and -F through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 18:56:13 +0000 (19:56 +0100)]
ls: handle -p and -F through option_mask32

function                                             old     new   delta
display_single                                      1039    1044      +5
append_char                                           67      68      +1
display_files                                        399     396      -3
scan_and_display_dirs_recur                          545     541      -4
ls_main                                              736     722     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 6/-21)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: LIST_ID_NAME/ID_NUMERIC/LOPT/LONG are the same, merge as LONG
Denys Vlasenko [Mon, 23 Jan 2017 18:42:12 +0000 (19:42 +0100)]
ls: LIST_ID_NAME/ID_NUMERIC/LOPT/LONG are the same, merge as LONG

Also, handle -n and --full-time using option_mask32

function                                             old     new   delta
scan_and_display_dirs_recur                          548     545      -3
display_single                                      1053    1039     -14
ls_main                                              777     736     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-58)             Total: -58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: make -Z output compatible with GNU coreutils 8.25
Denys Vlasenko [Mon, 23 Jan 2017 18:30:14 +0000 (19:30 +0100)]
ls: make -Z output compatible with GNU coreutils 8.25

This also makes it clear that LIST_MODEBITS == LIST_LOPT

function                                             old     new   delta
ls_main                                              752     777     +25
display_files                                        400     399      -1
display_single                                      1055    1053      -2
my_stat                                              320     317      -3
packed_usage                                       32311   32280     -31
.rodata                                           168895  168864     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 25/-68)            Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: LIST_NLINKS/SIZE/DATE_TIME/SYMLINK are always the same, merge as LIST_LOPT
Denys Vlasenko [Mon, 23 Jan 2017 18:05:11 +0000 (19:05 +0100)]
ls: LIST_NLINKS/SIZE/DATE_TIME/SYMLINK are always the same, merge as LIST_LOPT

They are always set and cleared together

function                                             old     new   delta
append_char                                           69      68      -1
display_single                                       910     908      -2
ls_main                                              677     664     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16)             Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -s through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 17:43:43 +0000 (18:43 +0100)]
ls: handle -s through option_mask32

function                                             old     new   delta
scan_and_display_dirs_recur                          493     494      +1
sort_and_display_files                               424     423      -1
ls_main                                              682     677      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -i through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 17:34:11 +0000 (18:34 +0100)]
ls: handle -i through option_mask32

function                                             old     new   delta
sort_and_display_files                               420     424      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle -a and -A through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 17:23:19 +0000 (18:23 +0100)]
ls: handle -a and -A through option_mask32

function                                             old     new   delta
ls_main                                              685     682      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: handle all sort options through option_mask32
Denys Vlasenko [Mon, 23 Jan 2017 17:01:48 +0000 (18:01 +0100)]
ls: handle all sort options through option_mask32

function                                             old     new   delta
packed_usage                                       31007   31024     +17
my_stat                                              318     324      +6
sort_and_display_files                               419     420      +1
print_name                                           216     217      +1
sortcmp                                              228     216     -12
opt_flags                                             96      64     -32
ls_main                                              732     685     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 25/-91)            Total: -66 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: reorder tls_handshake_data fields for smaller size, tweak comments
Denys Vlasenko [Mon, 23 Jan 2017 15:37:04 +0000 (16:37 +0100)]
tls: reorder tls_handshake_data fields for smaller size, tweak comments

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: send EMPTY_RENEGOTIATION_INFO_SCSV in our client hello
Denys Vlasenko [Mon, 23 Jan 2017 15:12:17 +0000 (16:12 +0100)]
tls: send EMPTY_RENEGOTIATION_INFO_SCSV in our client hello

Hoped this can make cdn.kernel.org to like us more. Nope.
While at it, made error reporting more useful.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: set TLS_DEBUG to 0; placate a gcc indentation warning
Denys Vlasenko [Mon, 23 Jan 2017 00:15:13 +0000 (01:15 +0100)]
tls: set TLS_DEBUG to 0; placate a gcc indentation warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoseparate TLS code into a library, use in in wget
Denys Vlasenko [Mon, 23 Jan 2017 00:08:16 +0000 (01:08 +0100)]
separate TLS code into a library, use in in wget

A new applet, ssl_client, is the TLS debug thing now.
It doubles as wget's NOMMU helper.
In MMU mode, wget still forks, but then directly calls TLS code,
without execing.

This can also be applied to sendmail/popmail (SMTPS / SMTP+starttls support)
and nc --ssl (ncat, nmap's nc clone, has such option).

function                                             old     new   delta
tls_handshake                                          -    1691   +1691
tls_run_copy_loop                                      -     443    +443
ssl_client_main                                        -     128    +128
packed_usage                                       30978   31007     +29
wget_main                                           2508    2535     +27
applet_names                                        2553    2560      +7
...
xwrite_encrypted                                     360     342     -18
tls_main                                            2127       -   -2127
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 13/8 up/down: 2351/-2195)       Total: 156 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: -1 should be ignored by -l (and options which imply -l)
Denys Vlasenko [Sun, 22 Jan 2017 21:02:19 +0000 (22:02 +0100)]
ls: -1 should be ignored by -l (and options which imply -l)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: more correct handling of -c, -u
Denys Vlasenko [Sun, 22 Jan 2017 18:02:57 +0000 (19:02 +0100)]
ls: more correct handling of -c, -u

function                                             old     new   delta
my_stat                                              302     318     +16
packed_usage                                       30977   30969      -8
display_single                                       928     910     -18
sortcmp                                              258     228     -30
ls_main                                              776     732     -44
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 16/-100)           Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agols: replace -e with --full-time, add --group-directories-first, delete -K
Denys Vlasenko [Sun, 22 Jan 2017 16:32:20 +0000 (17:32 +0100)]
ls: replace -e with --full-time, add --group-directories-first, delete -K

-K and -e were non-standard

function                                             old     new   delta
static.ls_longopts                                     9      47     +38
ls_main                                              748     776     +28
display_single                                       901     928     +27
sortcmp                                              254     258      +4
ls_options                                            32      31      -1
opt_flags                                            100      96      -4
packed_usage                                       31032   30977     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 97/-60)             Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agoip: better --help
Denys Vlasenko [Sat, 21 Jan 2017 13:27:07 +0000 (14:27 +0100)]
ip: better --help

Was:
    Usage: ip [OPTIONS] address|route|link|tunnel|neigh|rule [COMMAND]

    ip [OPTIONS] OBJECT [COMMAND]
    where OBJECT := address|route|link|tunnel|neigh|rule
    OPTIONS := -f[amily] inet|inet6|link | -o[neline]

User: instead of repeating list of OBJECTs twice, you could at least
show available COMMANDs...

Now:
    Usage: ip [OPTIONS] address|route|link|tunnel|neigh|rule [COMMAND]

    OPTIONS := -f[amily] inet|inet6|link | -o[neline]
    COMMAND :=
    ip addr add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]
    ip route list|flush|add|del|change|append|replace|test ROUTE
    ip link set IFACE [up|down] [arp on|off] | show [IFACE]
    ip tunnel add|change|del|show [NAME]
        [mode ipip|gre|sit]
        [remote ADDR] [local ADDR] [ttl TTL]
    ip neigh show|flush [to PREFIX] [dev DEV] [nud STATE]
    ip rule [list] | add|del SELECTOR ACTION

While at it, tweak tc --help too (it stays disabled, thus no effect)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomore ip --help fixes
Denys Vlasenko [Sat, 21 Jan 2017 02:56:46 +0000 (03:56 +0100)]
more ip --help fixes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake --help texts smaller
Denys Vlasenko [Sat, 21 Jan 2017 02:46:35 +0000 (03:46 +0100)]
make --help texts smaller

function                                             old     new   delta
packed_usage                                       31035   30968     -67

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agomake --help texts more uniform
Denys Vlasenko [Sat, 21 Jan 2017 01:49:58 +0000 (02:49 +0100)]
make --help texts more uniform

function                                             old     new   delta
packed_usage                                       31062   31035     -27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: reorder tls_state fields for smaller offsets
Denys Vlasenko [Sat, 21 Jan 2017 01:07:59 +0000 (02:07 +0100)]
tls: reorder tls_state fields for smaller offsets

function                                             old     new   delta
xwrite_encrypted                                     363     360      -3
xwrite_and_update_handshake_hash                     117     114      -3
tls_xread_handshake_block                             72      69      -3
tls_error_die                                        211     202      -9
tls_get_outbuf                                        64      49     -15
tls_main                                            2163    2127     -36
tls_xread_record                                     702     639     -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-132)           Total: -132 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: send SNI in the client hello
Denys Vlasenko [Fri, 20 Jan 2017 21:48:41 +0000 (22:48 +0100)]
tls: send SNI in the client hello

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: check size on "MAC-only, no crypt" code path too
Denys Vlasenko [Fri, 20 Jan 2017 20:23:10 +0000 (21:23 +0100)]
tls: check size on "MAC-only, no crypt" code path too

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: AES decrypt does one unnecessary memmove
Denys Vlasenko [Fri, 20 Jan 2017 20:19:38 +0000 (21:19 +0100)]
tls: AES decrypt does one unnecessary memmove

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 years agotls: make input buffer grow as needed
Denys Vlasenko [Fri, 20 Jan 2017 19:27:06 +0000 (20:27 +0100)]
tls: make input buffer grow as needed

As it turns out, it goes only up to "inbuf_size:4608"
for kernel.org - fixed 18kb buffer was x4 larger than necessary.

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