Compare commits

...
12 Commits
Author SHA1 Message Date
Denys Vlasenko bd75474639 Bump version to 1.31.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 10:45:05 +02:00
Denys Vlasenko ebc1c38a92 dpkg-deb: work around bogus error message when working with XZ compressed packages
function                                             old     new   delta
unpack_xz_stream                                    2309    2317      +8
bb_full_fd_action                                    464     472      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Denys Vlasenko be11940911 telnet: fix uninitialized variable bug
function                                             old     new   delta
telnet_main                                         1236    1238      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Denys Vlasenko 49a8839638 ash: fix BASE##nn bashism for bases 36..64
function                                             old     new   delta
evaluate_string                                      876     932     +56

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Denys Vlasenko 3004510fdc ash: fix BASE##nn bashism to accept letter 'digits' for bases > 9
function                                             old     new   delta
evaluate_string                                      873     876      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
David Demelier d6a8784f27 wget: increase redirections limit
Some hosting services like sourceforge perform a lot of relocations
before actually serving the file. Example of current limitation:

    busybox wget http://sourceforge.net/projects/fluxbox/files/fluxbox/1.3.7/fluxbox-1.3.7.tar.xz
    Connecting to sourceforge.net (216.105.38.13:80)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to sourceforge.net (216.105.38.13:443)
    Connecting to downloads.sourceforge.net (216.105.38.13:443)
    wget: too many redirections

Signed-off-by: David Demelier <markand@malikania.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Denys Vlasenko a1c7a9e976 hush: fix "set -o INVALID" affecting -e flag state
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Brian Foley 2f3352682e dc: Parse error & fix out of bounds read in xc_program_printString
function                                             old     new   delta
xc_program_print                                     712     735     +23

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Brian Foley 50ba92128b dc: Fix segfault when executing strings generated using asciify
function                                             old     new   delta
zxc_vm_process                                      6884    6891      +7

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Brian Foley 4699b93244 dc: execute shouldn't pop if stack head is not a string
This matches the behaviour of both GNU dc (as specified in
its man page), and BSD dc (where stack_popstring() pops
only if the head is a string.)

Add a couple of tests to verify this behavior.

function                                             old     new   delta
zxc_vm_process                                      6882    6884      +2

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Denys Vlasenko 244c0ebb4f ash: fix set -o to not show "nameless" options
Patch by Martijn Dekker <martijn@inlv.org>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
Ron Yorston c88d3ec458 ash: only catch unexpected exceptions in PS1 expansion
Commit d1a2fa2a4 (ash: catch error in arithmetic expansion in PS1)
catches all exceptions raised by expandarg().  Some exceptions, such as
the EXEXIT raised when command expansion is used, are expected:

   export PS1='$(echo "$ ")'

These should be processed normally or the shell hangs at the prompt.

function                                             old     new   delta
expandstr                                            344     353      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:54:40 +02:00
11 changed files with 120 additions and 28 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 31
SUBLEVEL = 0
SUBLEVEL = 1
EXTRAVERSION =
NAME = Unnamed
+19 -1
View File
@@ -96,6 +96,24 @@ unpack_xz_stream(transformer_state_t *xstate)
*/
do {
if (membuf[iobuf.in_pos] != 0) {
/* There is more data, but is it XZ data?
* Example: dpkg-deb -f busybox_1.30.1-4_amd64.deb
* reads control.tar.xz "control" file
* inside the ar archive, but tar.xz
* extraction code reaches end of xz data,
* reached this code and reads the beginning
* of data.tar.xz's ar header, which isn't xz data,
* and prints "corrupted data".
* The correct solution is to not read
* past nested archive (to simulate EOF).
* This is a workaround:
*/
if (membuf[iobuf.in_pos] != 0xfd) {
/* It's definitely not a xz signature
* (which is 0xfd,"7zXZ",0x00).
*/
goto end;
}
xz_dec_reset(state);
goto do_run;
}
@@ -128,7 +146,7 @@ unpack_xz_stream(transformer_state_t *xstate)
break;
}
}
end:
xz_dec_end(state);
free(membuf);
+1 -1
View File
@@ -25,7 +25,7 @@
#define STREAM_HEADER_SIZE 12
#define HEADER_MAGIC "\3757zXZ"
#define HEADER_MAGIC "\375""7zXZ"
#define HEADER_MAGIC_SIZE 6
#define FOOTER_MAGIC "YZ"
+8 -5
View File
@@ -18,7 +18,7 @@
* was seen to cause largish delays when user tries to ^C a file copy.
* Let's use a saner size.
* Note: needs to be >= max(CONFIG_FEATURE_COPYBUF_KB),
* or else "copy to eof" code will use neddlesly short reads.
* or else "copy to eof" code will use needlesly short reads.
*/
#define SENDFILE_BIGBUF (16*1024*1024)
@@ -60,10 +60,13 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
ssize_t rd;
if (sendfile_sz) {
rd = sendfile(dst_fd, src_fd, NULL,
size > sendfile_sz ? sendfile_sz : size);
if (rd >= 0)
goto read_ok;
/* dst_fd == -1 is a fake, else... */
if (dst_fd >= 0) {
rd = sendfile(dst_fd, src_fd, NULL,
size > sendfile_sz ? sendfile_sz : size);
if (rd >= 0)
goto read_ok;
}
sendfile_sz = 0; /* do not try sendfile anymore */
}
#if CONFIG_FEATURE_COPYBUF_KB > 4
+14 -5
View File
@@ -4973,7 +4973,9 @@ static void dc_parse_string(void)
xc_parse_pushInst_and_Index(XC_INST_STR, len);
bc_vec_push(&G.prog.strs, &str);
// Explanation needed here
// Add an empty function so that if zdc_program_execStr ever needs to
// parse the string into code (from the 'x' command) there's somewhere
// to store the bytecode.
xc_program_add_fn();
p->func = xc_program_func(p->fidx);
@@ -5454,11 +5456,13 @@ static void xc_program_printString(const char *str)
char *n;
c = *str++;
n = strchr(esc, c); // note: c can be NUL
if (!n) {
n = strchr(esc, c); // note: if c is NUL, n = \0 at end of esc
if (!n || !c) {
// Just print the backslash and following character
bb_putchar('\\');
++G.prog.nchars;
// But if we're at the end of the string, stop
if (!c) break;
} else {
if (n - esc == 0) // "\n" ?
G.prog.nchars = SIZE_MAX;
@@ -6398,7 +6402,11 @@ static BC_STATUS zdc_program_asciify(void)
str = xzalloc(2);
str[0] = c;
//str[1] = '\0'; - already is
bc_vec_push(&G.prog.strs, &str);
idx = bc_vec_push(&G.prog.strs, &str);
// Add an empty function so that if zdc_program_execStr ever needs to
// parse the string into code (from the 'x' command) there's somewhere
// to store the bytecode.
xc_program_add_fn();
dup:
res.t = XC_RESULT_STR;
res.d.id.idx = idx;
@@ -6521,7 +6529,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond)
if (s || !BC_PROG_STR(n)) goto exit;
sidx = n->rdx;
} else
goto exit;
goto exit_nopop;
}
fidx = sidx + BC_PROG_REQ_FUNCS;
@@ -6561,6 +6569,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond)
RETURN_STATUS(BC_STATUS_SUCCESS);
exit:
bc_vec_pop(&G.prog.results);
exit_nopop:
RETURN_STATUS(s);
}
#define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS)
+1 -1
View File
@@ -248,7 +248,7 @@ static void handle_net_input(int len)
{
byte c;
int i;
int cstart = cstart; /* for compiler */
int cstart = 0;
i = 0;
//bb_error_msg("[%u,'%.*s']", G.telstate, len, G.buf);
+1 -1
View File
@@ -1109,7 +1109,7 @@ static void download_one_url(const char *url)
* We are not sure it exists on remote side */
}
redir_limit = 5;
redir_limit = 16;
resolve_lsa:
lsa = xhost2sockaddr(server.host, server.port);
if (!(option_mask32 & WGET_OPT_QUIET)) {
+4
View File
@@ -11091,6 +11091,8 @@ plus_minus_o(char *name, int val)
return 1;
}
for (i = 0; i < NOPTS; i++) {
if (optnames(i)[0] == '\0')
continue;
if (val) {
out1fmt("%-16s%s\n", optnames(i), optlist[i] ? "on" : "off");
} else {
@@ -13126,6 +13128,8 @@ expandstr(const char *ps, int syntax_type)
if (setjmp(jmploc.loc) == 0) {
exception_handler = &jmploc;
expandarg(&n, NULL, EXP_QUOTED);
} else if (exception_type == EXEXIT) {
exitshell();
}
exception_handler = savehandler;
RESTORE_INT(saveint);
+9 -11
View File
@@ -9824,9 +9824,12 @@ static int set_mode(int state, char mode, const char *o_opt)
IF_HUSH_MODE_X(G_x_mode = state;)
IF_HUSH_MODE_X(if (G.x_mode_fd <= 0) G.x_mode_fd = dup_CLOEXEC(2, 10);)
break;
case 'e':
G.o_opt[OPT_O_ERREXIT] = state;
break;
case 'o':
if (!o_opt) {
/* "set -+o" without parameter.
/* "set -o" or "set +o" without parameter.
* in bash, set -o produces this output:
* pipefail off
* and set +o:
@@ -9847,9 +9850,7 @@ static int set_mode(int state, char mode, const char *o_opt)
G.o_opt[idx] = state;
break;
}
case 'e':
G.o_opt[OPT_O_ERREXIT] = state;
break;
/* fall through to error */
default:
return EXIT_FAILURE;
}
@@ -10931,8 +10932,10 @@ static int FAST_FUNC builtin_set(char **argv)
if (arg[0] != '+' && arg[0] != '-')
break;
for (n = 1; arg[n]; ++n) {
if (set_mode((arg[0] == '-'), arg[n], argv[1]))
goto error;
if (set_mode((arg[0] == '-'), arg[n], argv[1])) {
bb_error_msg("%s: %s: invalid option", "set", arg);
return EXIT_FAILURE;
}
if (arg[n] == 'o' && argv[1])
argv++;
}
@@ -10962,11 +10965,6 @@ static int FAST_FUNC builtin_set(char **argv)
G.global_argc = 1 + string_array_len(pp + 1);
return EXIT_SUCCESS;
/* Nothing known, so abort */
error:
bb_error_msg("%s: %s: invalid option", "set", arg);
return EXIT_FAILURE;
}
#endif
+27 -2
View File
@@ -538,9 +538,34 @@ static arith_t strto_arith_t(const char *nptr, char **endptr)
n = 0;
nptr = *endptr + 1;
/* bash allows "N#" (empty "nnnn" part) */
while (isdigit(*nptr)) {
for (;;) {
unsigned digit = (unsigned)*nptr - '0';
if (digit >= 10) {
/* *nptr is not 0..9 */
if (*nptr > 'z')
break; /* this rejects e.g. $((64#~)) */
/* in bases up to 36, case does not matter for a-z */
digit = (unsigned)(*nptr | 0x20) - ('a' - 10);
if (base > 36 && *nptr <= '_') {
/* otherwise, A-Z,@,_ are 36..61,62,63 */
if (*nptr == '@')
digit = 62;
else if (*nptr == '_')
digit = 63;
else if (digit < 36) /* A-Z */
digit += 36 - 10;
else
break; /* error, such as [ or \ */
}
//bb_error_msg("ch:'%c'%d digit:%u", *nptr, *nptr, digit);
//if (digit < 10) - example where we need this?
// break;
}
if (digit >= base)
break;
/* bash does not check for overflows */
n = n * base + (*nptr++ - '0');
n = n * base + digit;
nptr++;
}
*endptr = (char*)nptr;
return n;
+35
View File
@@ -44,6 +44,41 @@ testing "dc complex without spaces (multiple args)" \
optional FEATURE_DC_BIG
# All tests below depend on FEATURE_DC_BIG
testing "dc: x should execute strings" \
"dc -e'[40 2 +] x f'" \
"42\n" \
"" ""
testing "dc: x should not execute or pop non-strings" \
"dc -e'42 x f'" \
"42\n" \
"" ""
testing "dc: x should work with strings created from a" \
"dc -e'42 112 a x'" \
"42\n" \
"" ""
testing "dc: p should print invalid escapes" \
"dc -e '[\q] p'" \
"\\q\n" \
"" ""
testing "dc: p should print trailing backslashes" \
"dc -e '[q\] p'" \
"q\\\\\n" \
"" ""
testing "dc: p should parse/print single backslashes" \
"dc -e '[\] p'" \
"\\\\\n" \
"" ""
testing "dc: p should print single backslash strings" \
"dc -e '92 a p'" \
"\\\\\n" \
"" ""
testing "dc read" \
"dc -finput" \
"2\n9\n1\n" \