Compare commits

...
12 Commits
Author SHA1 Message Date
Denys Vlasenko db726ae0c6 Bump version to 1.33.2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-24 14:27:03 +01:00
Denys Vlasenko bb61205290 hush: fix handling of "cmd && &"
function                                             old     new   delta
done_pipe                                            213     231     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 83a4967e50)
2021-11-23 05:31:30 +01:00
Denys Vlasenko 56a335378a hush: fix handling of \^C and "^C"
function                                             old     new   delta
parse_stream                                        2238    2252     +14
encode_string                                        243     256     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)               Total: 27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 1b7a9b68d0)
2021-11-23 05:31:30 +01:00
Denys Vlasenko 5b939a6d29 ash: parser: Fix VSLENGTH parsing with trailing garbage
Let's adopt Herbert Xu's patch, not waiting for it to reach dash git:
hush already has a similar fix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 53a7a9cd8c)
2021-11-23 05:31:30 +01:00
Denys Vlasenko d326be2850 unlzma: fix a case where we could read before beginning of buffer
Testcase:

  21 01 01 00 00 00 00 00 e7 01 01 01 ef 00 df b6
  00 17 02 10 11 0f ff 00 16 00 00

Unfortunately, the bug is not reliably causing a segfault,
the behavior depends on what's in memory before the buffer.

function                                             old     new   delta
unpack_lzma_stream                                  2762    2768      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 04f052c56d)
2021-11-23 05:31:30 +01:00
Denys Vlasenko bcc5b0e6ca Bump version to 1.33.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-03 20:07:13 +02:00
Denys Vlasenko 611bbfc148 ash: fix ${unset_var/pattern/repl}
function                                             old     new   delta
subevalvar                                          1349    1353      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-03 20:06:49 +02:00
Samuel Sapalski 23dd1c75b7 decompress_gunzip: Fix DoS if gzip is corrupt
On certain corrupt gzip files, huft_build will set the error bit on
the result pointer. If afterwards abort_unzip is called huft_free
might run into a segmentation fault or an invalid pointer to
free(p).

In order to mitigate this, we check in huft_free if the error bit
is set and clear it before the linked list is freed.

Signed-off-by: Samuel Sapalski <samuel.sapalski@nokia.com>
Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-03 14:50:09 +02:00
Denys Vlasenko 89358a7131 traceroute: fix option parsing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-09 00:28:26 +01:00
Bernd Kuhls 39b71881b8 update_passwd: fix context variable
Commit
https://git.busybox.net/busybox/commit/libbb/update_passwd.c?id=2496616b0a8d1c80cd1416b73a4847b59b9f969a

changed the variable used from context to seuser but forgot this
change resulting in build errors detected by buildroot autobuilders:

http://autobuild.buildroot.net/results/b89/b89b7d0f0601bb706e76cea31cf4e43326e5540c//build-end.log

libbb/update_passwd.c:51:11: error: 'context' undeclared (first use in
 this function); did you mean 'ucontext'?
   freecon(context);

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-09 00:28:26 +01:00
Denys Vlasenko 67cc582d42 ash: make a strdup copy of $HISTFILE for line editing
Otherwise if $HISTFILE is unset or reassigned, bad things can happen.

function                                             old     new   delta
ash_main                                            1210    1218      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-09 00:28:26 +01:00
Maxim Storchak ee1e0987e4 httpd: fix offset for sendfile
If the Range: header is not present it the request,
the offset passed to sendfile is wrong,
and httpd falls back to the read-write loop.

function                                             old     new   delta
send_file_and_exit                                   857     865      +8
handle_incoming_and_exit                            2239    2230      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 8/-9)               Total: -1 bytes

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-09 00:28:26 +01:00
20 changed files with 71 additions and 23 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 33
SUBLEVEL = 0
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
+10 -2
View File
@@ -220,10 +220,20 @@ static const uint8_t border[] ALIGN1 = {
* each table.
* t: table to free
*/
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
#define ERR_RET ((huft_t*)(uintptr_t)1)
static void huft_free(huft_t *p)
{
huft_t *q;
/*
* If 'p' has the error bit set we have to clear it, otherwise we might run
* into a segmentation fault or an invalid pointer to free(p)
*/
if (BAD_HUFT(p)) {
p = (huft_t*)((uintptr_t)(p) ^ (uintptr_t)(ERR_RET));
}
/* Go through linked list, freeing from the malloced (t[-1]) address. */
while (p) {
q = (--p)->v.t;
@@ -289,8 +299,6 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
* or a valid pointer to a Huffman table, ORed with 0x1 if incompete table
* is given: "fixed inflate" decoder feeds us such data.
*/
#define BAD_HUFT(p) ((uintptr_t)(p) & 1)
#define ERR_RET ((huft_t*)(uintptr_t)1)
static huft_t* huft_build(const unsigned *b, const unsigned n,
const unsigned s, const struct cp_ext *cp_ext,
unsigned *m)
+4 -1
View File
@@ -290,8 +290,11 @@ unpack_lzma_stream(transformer_state_t *xstate)
uint32_t pos;
pos = buffer_pos - rep0;
if ((int32_t)pos < 0)
if ((int32_t)pos < 0) {
pos += header.dict_size;
if ((int32_t)pos < 0)
goto bad;
}
match_byte = buffer[pos];
do {
int bit;
+1 -1
View File
@@ -48,7 +48,7 @@ static void check_selinux_update_passwd(const char *username)
bb_simple_error_msg_and_die("SELinux: access denied");
}
if (ENABLE_FEATURE_CLEAN_UP)
freecon(context);
freecon(seuser);
}
#else
# define check_selinux_update_passwd(username) ((void)0)
+3 -3
View File
@@ -1871,7 +1871,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
send_headers(HTTP_OK);
#if ENABLE_FEATURE_USE_SENDFILE
{
off_t offset = range_start;
off_t offset = (range_start < 0) ? 0 : range_start;
while (1) {
/* sz is rounded down to 64k */
ssize_t sz = MAXINT(ssize_t) - 0xffff;
@@ -2486,8 +2486,8 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
if (STRNCASECMP(iobuf, "Range:") == 0) {
/* We know only bytes=NNN-[MMM] */
char *s = skip_whitespace(iobuf + sizeof("Range:")-1);
if (is_prefixed_with(s, "bytes=")) {
s += sizeof("bytes=")-1;
s = is_prefixed_with(s, "bytes=");
if (s) {
range_start = BB_STRTOOFF(s, &s, 10);
if (s[0] != '-' || range_start < 0) {
range_start = -1;
+1 -1
View File
@@ -896,7 +896,7 @@ traceroute_init(int op, char **argv)
op |= getopt32(argv, "^"
OPT_STRING
"\0" "-1:x-x" /* minimum 1 arg */
"\0" "-1" /* minimum 1 arg */
, &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str
, &source, &waittime_str, &pausemsecs_str, &first_ttl_str
);
+7 -9
View File
@@ -7011,7 +7011,8 @@ subevalvar(char *start, char *str, int strloc,
slash_pos = -1;
if (repl) {
slash_pos = expdest - ((char *)stackblock() + strloc);
STPUTC('/', expdest);
if (!(flag & EXP_DISCARD))
STPUTC('/', expdest);
//bb_error_msg("repl+1:'%s'", repl + 1);
p = argstr(repl + 1, (flag & EXP_DISCARD) | EXP_TILDE); /* EXP_TILDE: echo "${v/x/~}" expands ~ ! */
*repl = '/';
@@ -12634,7 +12635,7 @@ parsesub: {
do {
STPUTC(c, out);
c = pgetc_eatbnl();
} while (!subtype && isdigit(c));
} while ((subtype == 0 || subtype == VSLENGTH) && isdigit(c));
} else if (c != '}') {
/* $[{[#]]<specialchar>[}] */
int cc = c;
@@ -12664,11 +12665,6 @@ parsesub: {
} else
goto badsub;
if (c != '}' && subtype == VSLENGTH) {
/* ${#VAR didn't end with } */
goto badsub;
}
if (subtype == 0) {
static const char types[] ALIGN1 = "}-+?=";
/* ${VAR...} but not $VAR or ${#VAR} */
@@ -12725,6 +12721,8 @@ parsesub: {
#endif
}
} else {
if (subtype == VSLENGTH && c != '}')
subtype = 0;
badsub:
pungetc();
}
@@ -14499,7 +14497,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
if (sflag || minusc == NULL) {
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
if (line_input_state) {
const char *hp = lookupvar("HISTFILE");
if (!hp) {
hp = lookupvar("HOME");
@@ -14513,7 +14511,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
}
}
if (hp)
line_input_state->hist_file = hp;
line_input_state->hist_file = xstrdup(hp);
# if ENABLE_FEATURE_SH_HISTFILESIZE
hp = lookupvar("HISTFILESIZE");
line_input_state->max_history = size_from_HISTFILESIZE(hp);
@@ -0,0 +1 @@
SHELL: line 1: : not found
+2
View File
@@ -0,0 +1,2 @@
# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
$THIS_SH -c '\' SHELL
@@ -0,0 +1 @@
SHELL: line 1: -: not found
+2
View File
@@ -0,0 +1,2 @@
# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
$THIS_SH -c '"-"' SHELL
@@ -1,2 +1,3 @@
Ok:0
@@ -1,3 +1,5 @@
unset v
echo ${v/*/w}
v=''
echo ${v/*/w}
echo Ok:$?
+16 -1
View File
@@ -3694,9 +3694,10 @@ static void debug_print_tree(struct pipe *pi, int lvl)
pin = 0;
while (pi) {
fdprintf(2, "%*spipe %d %sres_word=%s followup=%d %s\n",
fdprintf(2, "%*spipe %d #cmds:%d %sres_word=%s followup=%d %s\n",
lvl*2, "",
pin,
pi->num_cmds,
(IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""),
RES[pi->res_word],
pi->followup, PIPE[pi->followup]
@@ -3839,6 +3840,9 @@ static void done_pipe(struct parse_context *ctx, pipe_style type)
#endif
/* Replace all pipes in ctx with one newly created */
ctx->list_head = ctx->pipe = pi;
/* for cases like "cmd && &", do not be tricked by last command
* being null - the entire {...} & is NOT null! */
not_null = 1;
} else {
no_conv:
ctx->pipe->followup = type;
@@ -5235,6 +5239,11 @@ static int encode_string(o_string *as_string,
}
#endif
o_addQchr(dest, ch);
if (ch == SPECIAL_VAR_SYMBOL) {
/* Convert "^C" to corresponding special variable reference */
o_addchr(dest, SPECIAL_VAR_QUOTED_SVS);
o_addchr(dest, SPECIAL_VAR_SYMBOL);
}
goto again;
#undef as_string
}
@@ -5346,6 +5355,11 @@ static struct pipe *parse_stream(char **pstring,
if (ch == '\n')
continue; /* drop \<newline>, get next char */
nommu_addchr(&ctx.as_string, '\\');
if (ch == SPECIAL_VAR_SYMBOL) {
nommu_addchr(&ctx.as_string, ch);
/* Convert \^C to corresponding special variable reference */
goto case_SPECIAL_VAR_SYMBOL;
}
o_addchr(&ctx.word, '\\');
if (ch == EOF) {
/* Testcase: eval 'echo Ok\' */
@@ -5670,6 +5684,7 @@ static struct pipe *parse_stream(char **pstring,
/* Note: nommu_addchr(&ctx.as_string, ch) is already done */
switch (ch) {
case_SPECIAL_VAR_SYMBOL:
case SPECIAL_VAR_SYMBOL:
/* Convert raw ^C to corresponding special variable reference */
o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
@@ -0,0 +1 @@
hush: can't execute '': No such file or directory
+2
View File
@@ -0,0 +1,2 @@
# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
$THIS_SH -c '\' SHELL
@@ -0,0 +1 @@
hush: can't execute '-': No such file or directory
+2
View File
@@ -0,0 +1,2 @@
# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
$THIS_SH -c '"-"' SHELL
+13 -4
View File
@@ -8,14 +8,23 @@
# Damaged encrypted streams
testing "unlzma (bad archive 1)" \
"unlzma <unlzma_issue_1.lzma >/dev/null; echo \$?" \
"1
"unlzma <unlzma_issue_1.lzma 2>&1 >/dev/null; echo \$?" \
"unlzma: corrupted data
1
" "" ""
# Damaged encrypted streams
testing "unlzma (bad archive 2)" \
"unlzma <unlzma_issue_2.lzma >/dev/null; echo \$?" \
"1
"unlzma <unlzma_issue_2.lzma 2>&1 >/dev/null; echo \$?" \
"unlzma: corrupted data
1
" "" ""
# Damaged encrypted streams
testing "unlzma (bad archive 3)" \
"unlzma <unlzma_issue_3.lzma 2>&1 >/dev/null; echo \$?" \
"unlzma: corrupted data
1
" "" ""
exit $FAILCOUNT
Binary file not shown.