Commit Graph

150 Commits

Author SHA1 Message Date
pepe
da516fe917 :( 2023-08-11 21:21:58 +00:00
Denys Vlasenko
dd79e1d4d3 fix [ --help ] and [[ --help ]]
function                                             old     new   delta
show_usage_if_dash_dash_help                          72      79      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-08-30 17:12:34 +02:00
Ron Yorston
5a9d2b6e02 libbb: make '--help' handling more consistent
Running an applet with '--help' as its only argument is treated
as a special case.  If additional arguments follow '--help' the
behaviour is inconsistent:

- applets which call single_argv() print help and do nothing else;

- applets which call getopt() report "unrecognized option '--help'"
  and print help anyway;

- expr says "expr: syntax error" and doesn't print help;

- printenv silently ignores '--help', prints any other variables
  and doesn't print help;

- realpath says "--help: No such file or directory", prints the path
  of any other files and doesn't print help.

If the first argument is '--help' ignore any other arguments and print
help.  This is more consistent and most likely what the user wanted.

See also commit 6bdfbc4cb (libbb: fix '--help' handling in
FEATURE_SH_NOFORK=y).

function                                             old     new   delta
show_usage_if_dash_dash_help                          75      69      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-6)               Total: -6 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-08-22 14:05:01 +02:00
Denys Vlasenko
9b6f44e040 style fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01 17:06:00 +02:00
Denys Vlasenko
ca466f385a *: slap on a few ALIGN* where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

function                                             old     new   delta
.rodata                                           108586  108460    -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126)           Total: -126 bytes
   text	   data	    bss	    dec	    hex	filename
 970412	   4219	   1848	 976479	  ee65f	busybox_old
 970286	   4219	   1848	 976353	  ee5e1	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 19:53:10 +01:00
Denys Vlasenko
5acf5e1f87 shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=y
function                                             old     new   delta
re_execed_comm                                         -      46     +46
main                                                  72      86     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0)               Total: 60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11 18:44:00 +02:00
YU Jincheng
5156b24553 Make const ptr assign as function call in clang
- This can act as memory barrier in clang to avoid
  read before assign of a const ptr

Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-09 22:30:45 +02:00
YU Jincheng
1f925038ab *: generalize "const trick"
While at it, change all "__asm__" to "asm"

Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-07 15:22:35 +02:00
Denys Vlasenko
03ed86b39e libbb: code shrink in main() and scripted_main()
function                                             old     new   delta
main                                                  68      65      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes
   text	   data	    bss	    dec	    hex	filename
   1472	    560	     16	   2048	    800	busybox_old
   1398	    552	     16	   1966	    7ae	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-28 17:40:59 +02:00
Denys Vlasenko
59243a86d9 busybox: fix "busybox --help busybox" not showing correct text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 08:53:42 +02:00
Denys Vlasenko
f26e5634b1 echo: special case "echo --help": it should not show help text
While at it, fix "busybox --help echo" and other special applets to still print
the help text.

function                                             old     new   delta
run_applet_and_exit                                  732     761     +29
show_usage_if_dash_dash_help                          70      78      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0)               Total: 37 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-15 17:44:53 +01:00
Denys Vlasenko
6bdfbc4cb5 libbb: fix '--help' handling in FEATURE_SH_NOFORK=y
Most BusyBox applets respond to the '--help' option by printing
a usage message.  This is normally handled by busybox_main() so
applet main routines don't have support for '--help'.

In standalone shell mode with FEATURE_SH_NOFORK enabled nofork
applets are invoked directly, bypassing busybox_main().  This
results in inconsistent handling of '--help':

- applets which call getopt() report "unrecognized option '--help'"
  and print help anyway;

- realpath says "--help: No such file or directory" and doesn't
  print help;

- usleep says "invalid number '--help'" and doesn't print help.

Avoid inconsistency by checking for '--help' in run_nofork_applet().

Bug found by Ron Yorston.

function                                             old     new   delta
show_usage_if_dash_dash_help                           -      70     +70
run_nofork_applet                                    347     362     +15
run_applet_no_and_exit                               432     365     -67
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67)             Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-18 23:30:24 +01:00
Ron Yorston
59120c3303 libbb: code shrink and speed up find_applet_by_name()
find_applet_by_name() determines the appropriate range of applet
indices to check for the given name and performs a linear search in
applet_names[].

Revise the code so the index of the upper bound of the range, 'max',
isn't calculated.  Instead check the value of the first non-matching
character to see if we've reached the end of the range.

This new code speeds up the time to find a valid applet name by 6%
and halves the time to detect that a given name is invalid.  The
average time to detect an invalid name is now the same as for a valid
one.

function                                             old     new   delta
find_applet_by_name                                  155     133     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-22)             Total: -22 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-02 14:16:38 +01:00
Denys Vlasenko
aaa0709e7b libbb: do not open-code __errno_location() call
Thanks dalias!

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 01:44:26 +02:00
Denys Vlasenko
b1c7a66ca6 libbb: extend "errno pointer" trick to other than __GLIBC__
Savings on musl:

function                                             old     new   delta
resume_main                                          582     614     +32
lbb_prepare                                            -      20     +20
seq_main                                             432     449     +17
fgetsetversion                                        74      88     +14
...
script_main                                         1207    1180     -27
close_silently                                        28       -     -28
shell_builtin_ulimit                                 655     626     -29
lineedit_read_key                                    280     247     -33
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 25/123 up/down: 182/-882)      Total: -700 bytes
   text	   data	    bss	    dec	    hex	filename
1005858	    551	   5676	1012085	  f7175	busybox_old
1005136	    551	   5680	1011367	  f6ea7	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 00:34:44 +02:00
Denys Vlasenko
67e1529b92 nologin: make it possible to build it as single applet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 15:05:22 +02:00
Denys Vlasenko
af7169b4a7 clang/llvm 9 fix - do not eliminate a store to a fake "const"
This is *much* better (9 kbytes better) than dropping "*const"
optimization trick.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 12:12:22 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Ron Yorston
3193cb56d6 libbb: mark scripted_main() as externally visible
Building with individual binaries enabled fails when embedded
script applets are included:

   /tmp/ccIvMFZg.o: In function `main':
   applet.c:(.text.main+0x20): undefined reference to `scripted_main'

Mark scripted_main() as externally visible.

Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-30 16:46:27 +01:00
Denys Vlasenko
ff65355b8a single-applet build --help had extra \n, remove
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-01 16:54:30 +01:00
Ron Yorston
71df2d3589 hush: allow hush to run embedded scripts
Embedded scripts require a shell to be present in the BusyBox
binary.  Allow either ash or hush to be used for this purpose.
If both are enabled ash takes precedence.

The size of the binary is unchanged in the default configuration:
both ash and hush are present but support for embedded scripts
isn't compiled into hush.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 16:13:07 +01:00
Ron Yorston
d1b2ae2d04 busybox: add '--show SCRIPT' option to display scripts
Add an option to allow the content of embedded scripts to be
displayed.  This includes applet scripts, custom scripts and the
.profile script.

function                                             old     new   delta
busybox_main                                         624     701     +77
find_script_by_name                                    -      24     +24
scripted_main                                         41      35      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 101/-6)             Total: 95 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-18 19:19:29 +01:00
Ron Yorston
3778898f97 Treat custom and applet scripts as applets
BusyBox has support for embedded shell scripts.  Two types can be
distinguished:  custom scripts and scripts implementing applets.

Custom scripts should be placed in the 'embed' directory at build
time.  They are given a default applet configuration and appear
as applets to the user but no further configuration is possible.

Applet scripts are integrated with the BusyBox build system and
are intended to be used to ship standard applets that just happen
to be implemented as scripts.  They can be configured at build time
and appear just like native applets.

Such scripts should be placed in the 'applets_sh' directory.  A stub
C program should be written to provide the usual applet configuration
details and placed in a suitable subsystem directory.  It may be
helpful to have a configuration option to enable any dependencies the
script requires:  see the 'nologin' applet for an example.

function                                             old     new   delta
scripted_main                                          -      41     +41
applet_names                                        2773    2781      +8
applet_main                                         1600    1604      +4
i2cdetect_main                                       672     674      +2
applet_suid                                          100     101      +1
applet_install_loc                                   200     201      +1
applet_flags                                         100     101      +1
packed_usage                                       33180   33179      -1
tryexec                                              159     152      -7
evalcommand                                         1661    1653      -8
script_names                                           9       -      -9
packed_scripts                                       123     114      -9
complete_cmd_dir_file                                826     811     -15
shellexec                                            271     254     -17
find_command                                        1007     990     -17
busybox_main                                         642     624     -18
run_applet_and_exit                                  100      78     -22
find_script_by_name                                   51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 6/9 up/down: 58/-174)          Total: -116 bytes
   text	   data	    bss	    dec	    hex	filename
 950034	    477	   7296	 957807	  e9d6f	busybox_old
 949918	    477	   7296	 957691	  e9cfb	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-17 21:16:33 +01:00
Ron Yorston
c339c7f7b3 libarchive: add a function to unpack embedded data
Similar code to unpack embedded data is used to decompress usage
messages, embedded scripts and the config file (in the non-default
bbconfig applet).

Moving this code to a common function reduces the size of the default
build and hides more of the internals of libarchive.

function                                             old     new   delta
unpack_bz2_data                                        -     135    +135
bb_show_usage                                        137     157     +20
get_script_content                                    32      47     +15
unpack_scripts                                       119       -    -119
unpack_usage_messages                                124       -    -124
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/0 up/down: 170/-243)          Total: -73 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02 14:14:51 +01:00
Denys Vlasenko
0575c9932d busybox: show embedded scripts in applet list
function                                             old     new   delta
busybox_main                                         624     642     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 13:58:16 +01:00
Ron Yorston
151de441e7 ash: recognize embedded scripts in SH_STANDALONE mode
function                                             old     new   delta
find_script_by_name                                    -      51     +51
shellexec                                            254     271     +17
find_command                                         990    1007     +17
evalcommand                                         1653    1661      +8
doCommands                                          2233    2222     -11
run_applet_and_exit                                  128     100     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/4 up/down: 104/-52)            Total: 52 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 11:07:26 +01:00
Denys Vlasenko
aa2959c90d claenups for previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 10:28:04 +01:00
Denys Vlasenko
4f2ef4a836 ash: allow shell scripts to be embedded in the binary
To assist in the deployment of shell scripts it may be convenient
to embed them in the BusyBox binary.

'Embed scripts in the binary' takes any files in the directory
'embed', concatenates them with null separators, compresses them
and embeds them in the binary.

When scripts are embedded in the binary, scripts can be run as
'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism.

embed/nologin is provided as an example.

function                                             old     new   delta
packed_scripts                                         -     123    +123
unpack_scripts                                         -      87     +87
ash_main                                            1103    1171     +68
run_applet_and_exit                                   78     128     +50
get_script_content                                     -      32     +32
script_names                                           -      10     +10
expmeta                                              663     659      -4
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4)            Total: 366 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 10:15:13 +01:00
Denys Vlasenko
4c201c00a3 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-17 15:04:17 +02:00
Denys Vlasenko
253f555f01 usage: do not print trailing space for commands which have no arguments
function                                             old     new   delta
bb_show_usage                                        120     130     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-09 18:23:33 +02:00
Denys Vlasenko
38ccd6af8a 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>
2018-04-08 20:05:04 +02:00
Denys Vlasenko
a02a4e9830 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 15:19:25 +02:00
Denys Vlasenko
ddd1ee4443 libbb: simplify NOFORK/NOEXEC defines, move set_task_comm to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 14:09:23 +02:00
Denys Vlasenko
80e8e3cc05 noexec: consolidate code
function                                             old     new   delta
run_noexec_applet_and_exit                             -      61     +61
find_applet_by_name                                  128     124      -4
run_applet_no_and_exit                               441     434      -7
tryexec                                              169     152     -17
pseudo_exec_argv                                     338     321     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 61/-48)             Total: 13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 19:24:57 +02:00
Denys Vlasenko
f2cf1cc716 noexec: set comm field for noexecs
function                                             old     new   delta
set_task_comm                                          -      18     +18
tryexec                                              152     159      +7
pseudo_exec_argv                                     321     328      +7
main                                                 106      97      -9
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 34/-13)             Total: 23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-07 18:45:33 +02:00
Denys Vlasenko
147d2ce3dd standalone shell / prefer_applets: fix "exe" in comm fields
function                                             old     new   delta
main                                                  92     106     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 02:19:01 +02:00
Denys Vlasenko
f128bdbbd7 shell: make standalone shell tab-complete "busybox"
function                                             old     new   delta
busybox_main                                           -     624    +624
packed_usage                                       31758   31777     +19
applet_names                                        2638    2646      +8
applet_main                                         1528    1532      +4
applet_install_loc                                   191     192      +1
run_applet_and_exit                                  681      78    -603
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 656/-603)           Total: 53 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-29 00:59:24 +02:00
Denys Vlasenko
12a4f9afe7 libbb: do not die if setgid/setuid(real_id) on startup fails
Based on a patch from Steven McDonald <steven@steven-mcdonald.id.au>:

This makes 'unshare --user' work correctly in the case where the user's
shell is provided by busybox itself.

'unshare --user' creates a new user namespace without any uid mappings.
As a result, /bin/busybox is setuid nobody:nogroup within the
namespace, as that is the only user. However, since no uids are mapped,
attempting to call setgid/setuid fails, even though this would do
nothing:

  $ unshare --user ./busybox.broken ash
  ash: setgid: Invalid argument

'unshare --map-root-user' still works, but because Linux only allows
uid/gid mappings to be set up once, creating a root mapping makes such
a namespace useless for creating multi-user containers.

With this patch, setgid and setuid will not be called in the case where
they would do nothing, which is always the case inside a new user
namespace because all uids are effectively mapped to nobody:

  $ id -u
  1000
  $ ls -lh busybox.fixed
  -rwsr-xr-x    1 root     root      826.2K May 21 00:33 busybox.fixed
  $ unshare --user ./busybox.fixed ash
  $ id -u
  65534

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-10 09:17:43 +02:00
Denys Vlasenko
69a5ec9dcc main: fix the case where user has "halt" as login shell. Closes 9986
halt::0:0::/:/sbin/halt

function                                             old     new   delta
run_applet_and_exit                                  748     751      +3
run_applet_no_and_exit                               467     459      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-07 19:08:56 +02:00
Denys Vlasenko
d4e4fdb5ce fixes for bugs found by make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 21:31:16 +02:00
Denys Vlasenko
a8a075acfe busybox: stop depending on FEATURE_AUTOWIDTH for applet list
Many other appletw don't - they unconditionally use get_terminal_wodth(),
and here the amount of code saved by FEATURE_AUTOWIDTH=n is tiny.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11 10:52:24 +01:00
Denys Vlasenko
fe93624fb6 Automatically disable FEATURE_COMPRESS_USAGE for small builds.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-06 19:16:36 +01:00
Cristian Ionescu-Idbohrn
f1d76b64a0 appletlib: avoid warning on unused function ingroup
libbb/appletlib.c:558:12: warning: 'ingroup' defined but
                                   not used [-Wunused-function]
 static int ingroup(uid_t u, gid_t g)
            ^~~~~~~

That function is used only if FEATURE_SUID_CONFIG is also enabled.

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 12:01:15 +01:00
Denys Vlasenko
9cc3d3ab21 fix breakage found by mass one-applet builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 02:42:26 +01:00
Denys Vlasenko
7d877fc931 Do not print useless empty line after list of applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-28 01:29:28 +01:00
Denys Vlasenko
7e8218f9b2 Fix allnoconfig warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-18 21:42:44 +01:00
Denys Vlasenko
7f0ebbc69e hush: add commented-out debug printouts in "memleak" built-in
Allocation addresses of malloc() are jittery,
thought I had a mem leak in hush, but it was malloc variability.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 17:42:53 +02:00
Denys Vlasenko
215b0ca6e4 hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186
Run this in a "sh SCRIPT":

sha256sum /dev/null
echo END

sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s.
By this time, entire script is read, and buffered in a FILE object
from fopen("SCRIPT"). But fgetc() did not consume entire input.
exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'.
(this may be libc-specific).
This change of fd position *is shared with the parent*!

Now parent can read more, and it thinks there is another "echo END".
End result: two "echo END"s are run.

Fix this by _exit()ing instead.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-19 18:43:06 +02:00
Denys Vlasenko
f4f8fe841c build system: fix a few warnings for allnoconfig build
Not that allnoconfig build is useful in any way...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:43:28 +02:00
Ron Yorston
1b0dcc02dd libbb: suppress warning about run_applet_and_exit
When busybox is configured to contain a single applet an unnecessary
declaration of run_applet_and_exit results in a warning.  Move the
declaration to avoid this.

Reported-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:21:36 +02:00