Compare commits

...
6 Commits
Author SHA1 Message Date
Denys Vlasenko e50f74da70 Bump version to 1.24.2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-17 21:38:03 +01:00
Denys Vlasenko 9de318d63e scripts/trylink: fix static build with glibc again. Closes 8471
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-17 21:37:12 +01:00
Ari Sundholm be729c1d3b truncate: always set mode when opening file to avoid fortify errors
Busybox crashes due to no mode being given when opening:
$ ./busybox truncate -s 1M foo
*** invalid open64 call: O_CREAT without mode ***: ./busybox terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7338f)[0x7f66d921338f]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f66d92aac9c]
/lib/x86_64-linux-gnu/libc.so.6(+0xeb6aa)[0x7f66d928b6aa]
./busybox[0x4899f9]
======= Memory map: ========
00400000-004d0000 r-xp 00000000 00:1a 137559                             /home/ari/busybox/busybox
006cf000-006d0000 r--p 000cf000 00:1a 137559                             /home/ari/busybox/busybox
006d0000-006d1000 rw-p 000d0000 00:1a 137559                             /home/ari/busybox/busybox
006d1000-006d4000 rw-p 00000000 00:00 0
014e7000-01508000 rw-p 00000000 00:00 0                                  [heap]
7f66d8f8a000-7f66d8fa0000 r-xp 00000000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d8fa0000-7f66d919f000 ---p 00016000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d919f000-7f66d91a0000 rw-p 00015000 08:07 1579008                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66d91a0000-7f66d935b000 r-xp 00000000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d935b000-7f66d955a000 ---p 001bb000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d955a000-7f66d955e000 r--p 001ba000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d955e000-7f66d9560000 rw-p 001be000 08:07 1578994                    /lib/x86_64-linux-gnu/libc-2.19.so
7f66d9560000-7f66d9565000 rw-p 00000000 00:00 0
7f66d9565000-7f66d966a000 r-xp 00000000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d966a000-7f66d9869000 ---p 00105000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d9869000-7f66d986a000 r--p 00104000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d986a000-7f66d986b000 rw-p 00105000 08:07 1579020                    /lib/x86_64-linux-gnu/libm-2.19.so
7f66d986b000-7f66d988e000 r-xp 00000000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a64000-7f66d9a67000 rw-p 00000000 00:00 0
7f66d9a8a000-7f66d9a8d000 rw-p 00000000 00:00 0
7f66d9a8d000-7f66d9a8e000 r--p 00022000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a8e000-7f66d9a8f000 rw-p 00023000 08:07 1578981                    /lib/x86_64-linux-gnu/ld-2.19.so
7f66d9a8f000-7f66d9a90000 rw-p 00000000 00:00 0
7ffc47761000-7ffc47782000 rw-p 00000000 00:00 0                          [stack]
7ffc477ab000-7ffc477ad000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)
$

Fix this by simply always setting the mode, as it doesn't hurt even
when O_CREAT is not specified.

This bug is a regression introduced in fc3e40e, as xopen(), which
was originally used, would automatically set the mode.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(cherry picked from commit e111a16404)
2016-01-13 13:33:38 -05:00
Denys Vlasenko 092fabcf1d [g]unzip: fix recent breakage.
Also, do emit error message we so painstakingly pass from gzip internals

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 6bd3fff51a)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2015-12-02 00:03:42 -05:00
Denys Vlasenko 6767af17f1 unzip: test for bad archive SEGVing
function                                             old     new   delta
huft_build                                          1296    1300      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 1de25a6e87)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2015-12-01 11:05:07 -05:00
Denys Vlasenko 5c23f2566c Apply post-1.24.0 patches, bump version to 1.24.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 02:29:00 +02:00
9 changed files with 170 additions and 51 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 24
SUBLEVEL = 0
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
+24 -12
View File
@@ -305,11 +305,11 @@ static int huft_build(const unsigned *b, const unsigned n,
unsigned i; /* counter, current code */
unsigned j; /* counter */
int k; /* number of bits in current code */
unsigned *p; /* pointer into c[], b[], or v[] */
const unsigned *p; /* pointer into c[], b[], or v[] */
huft_t *q; /* points to current table */
huft_t r; /* table entry for structure assignment */
huft_t *u[BMAX]; /* table stack */
unsigned v[N_MAX]; /* values in order of bit length */
unsigned v[N_MAX + 1]; /* values in order of bit length. last v[] is never used */
int ws[BMAX + 1]; /* bits decoded stack */
int w; /* bits decoded */
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
@@ -324,7 +324,7 @@ static int huft_build(const unsigned *b, const unsigned n,
/* Generate counts for each bit length */
memset(c, 0, sizeof(c));
p = (unsigned *) b; /* cast allows us to reuse p for pointing to b */
p = b;
i = n;
do {
c[*p]++; /* assume all entries <= BMAX */
@@ -364,8 +364,12 @@ static int huft_build(const unsigned *b, const unsigned n,
*xp++ = j;
}
/* Make a table of values in order of bit lengths */
p = (unsigned *) b;
/* Make a table of values in order of bit lengths.
* To detect bad input, unused v[i]'s are set to invalid value UINT_MAX.
* In particular, last v[i] is never filled and must not be accessed.
*/
memset(v, 0xff, sizeof(v));
p = b;
i = 0;
do {
j = *p++;
@@ -432,7 +436,9 @@ static int huft_build(const unsigned *b, const unsigned n,
/* set up table entry in r */
r.b = (unsigned char) (k - w);
if (p >= v + n) {
if (/*p >= v + n || -- redundant, caught by the second check: */
*p == UINT_MAX /* do we access uninited v[i]? (see memset(v))*/
) {
r.e = 99; /* out of values--invalid code */
} else if (*p < s) {
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */
@@ -517,8 +523,9 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
e = t->e;
if (e > 16)
do {
if (e == 99)
abort_unzip(PASS_STATE_ONLY);;
if (e == 99) {
abort_unzip(PASS_STATE_ONLY);
}
bb >>= t->b;
k -= t->b;
e -= 16;
@@ -554,8 +561,9 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
e = t->e;
if (e > 16)
do {
if (e == 99)
if (e == 99) {
abort_unzip(PASS_STATE_ONLY);
}
bb >>= t->b;
k -= t->b;
e -= 16;
@@ -821,8 +829,9 @@ static int inflate_block(STATE_PARAM smallint *e)
b_dynamic >>= 4;
k_dynamic -= 4;
if (nl > 286 || nd > 30)
if (nl > 286 || nd > 30) {
abort_unzip(PASS_STATE_ONLY); /* bad lengths */
}
/* read in bit-length-code lengths */
for (j = 0; j < nb; j++) {
@@ -903,12 +912,14 @@ static int inflate_block(STATE_PARAM smallint *e)
bl = lbits;
i = huft_build(ll, nl, 257, cplens, cplext, &inflate_codes_tl, &bl);
if (i != 0)
if (i != 0) {
abort_unzip(PASS_STATE_ONLY);
}
bd = dbits;
i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &inflate_codes_td, &bd);
if (i != 0)
if (i != 0) {
abort_unzip(PASS_STATE_ONLY);
}
/* set up data for inflate_codes() */
inflate_codes_setup(PASS_STATE bl, bd);
@@ -996,6 +1007,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
error_msg = "corrupted data";
if (setjmp(error_jmp)) {
/* Error from deep inside zip machinery */
bb_error_msg(error_msg);
n = -1;
goto ret;
}
+15 -5
View File
@@ -106,7 +106,9 @@ static struct sort_key {
static char *get_key(char *str, struct sort_key *key, int flags)
{
int start = 0, end = 0, len, j;
int start = start; /* for compiler */
int end;
int len, j;
unsigned i;
/* Special case whole string, so we don't have to make a copy */
@@ -123,12 +125,15 @@ static char *get_key(char *str, struct sort_key *key, int flags)
end = len;
/* Loop through fields */
else {
unsigned char ch = 0;
end = 0;
for (i = 1; i < key->range[2*j] + j; i++) {
if (key_separator) {
/* Skip body of key and separator */
while (str[end]) {
if (str[end++] == key_separator)
while ((ch = str[end]) != '\0') {
end++;
if (ch == key_separator)
break;
}
} else {
@@ -136,7 +141,7 @@ static char *get_key(char *str, struct sort_key *key, int flags)
while (isspace(str[end]))
end++;
/* Skip body of key */
while (str[end]) {
while (str[end] != '\0') {
if (isspace(str[end]))
break;
end++;
@@ -144,8 +149,13 @@ static char *get_key(char *str, struct sort_key *key, int flags)
}
}
/* Remove last delim: "abc:def:" => "abc:def" */
if (key_separator && j && end != 0)
if (j && ch) {
//if (str[end-1] != key_separator)
// bb_error_msg(_and_die("BUG! "
// "str[start:%d,end:%d]:'%.*s'",
// start, end, (int)(end-start), &str[start]);
end--;
}
}
if (!j) start = end;
}
+1 -1
View File
@@ -64,7 +64,7 @@ int truncate_main(int argc UNUSED_PARAM, char **argv)
argv += optind;
while (*argv) {
int fd = open(*argv, flags);
int fd = open(*argv, flags, 0666);
if (fd < 0) {
if (errno != ENOENT || !(opts & OPT_NOCREATE)) {
bb_perror_msg("%s: open", *argv);
+16 -1
View File
@@ -1223,11 +1223,26 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
#endif
argv += optind;
if (argv[0]) {
const char *basedir = argv[0];
#if !BB_MMU
G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
close_on_exec_on(G.root_fd);
#endif
xchroot(argv[0]);
if (chroot(basedir) == 0)
basedir = "/";
#if !BB_MMU
else {
close(G.root_fd);
G.root_fd = -1;
}
#endif
/*
* If chroot failed, assume that we aren't root,
* and at least chdir to the specified DIR
* (older versions were dying with error message).
* If chroot worked, move current dir to new "/":
*/
xchdir(basedir);
}
#if ENABLE_FEATURE_FTP_AUTHENTICATION
+19 -6
View File
@@ -967,19 +967,30 @@ static void send_headers(int responseNum)
}
#endif
if (responseNum == HTTP_MOVED_TEMPORARILY) {
len += sprintf(iobuf + len, "Location: %s/%s%s\r\n",
/* Responding to "GET /dir" with
* "HTTP/1.0 302 Found" "Location: /dir/"
* - IOW, asking them to repeat with a slash.
* Here, overflow IS possible, can't use sprintf:
* mkdir test
* python -c 'print("get /test?" + ("x" * 8192))' | busybox httpd -i -h .
*/
len += snprintf(iobuf + len, IOBUF_SIZE-3 - len,
"Location: %s/%s%s\r\n",
found_moved_temporarily,
(g_query ? "?" : ""),
(g_query ? g_query : ""));
if (len > IOBUF_SIZE-3)
len = IOBUF_SIZE-3;
}
#if ENABLE_FEATURE_HTTPD_ERROR_PAGES
if (error_page && access(error_page, R_OK) == 0) {
strcat(iobuf, "\r\n");
len += 2;
if (DEBUG)
iobuf[len++] = '\r';
iobuf[len++] = '\n';
if (DEBUG) {
iobuf[len] = '\0';
fprintf(stderr, "headers: '%s'\n", iobuf);
}
full_write(STDOUT_FILENO, iobuf, len);
if (DEBUG)
fprintf(stderr, "writing error page: '%s'\n", error_page);
@@ -1021,8 +1032,10 @@ static void send_headers(int responseNum)
responseNum, responseString,
responseNum, responseString, infoString);
}
if (DEBUG)
if (DEBUG) {
iobuf[len] = '\0';
fprintf(stderr, "headers: '%s'\n", iobuf);
}
if (full_write(STDOUT_FILENO, iobuf, len) != len) {
if (verbose > 1)
bb_perror_msg("error");
+35 -24
View File
@@ -47,18 +47,22 @@ try() {
check_cc() {
local tempname="$(mktemp)"
local r
echo "int main(int argc,char**argv){return argv?argc:0;}" >"$tempname".c
# Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
# "-xc": C language. "/dev/null" is an empty source file.
if $CC $CPPFLAGS $CFLAGS $1 -shared -xc /dev/null -o "$tempname".o >/dev/null 2>&1; then
echo "$1";
else
echo "$2";
fi
rm -f "$tempname" "$tempname".o
# Was using "-xc /dev/null", but we need a valid C program.
# "eval" may be needed if CFLAGS can contain
# '... -D"BB_VER=KBUILD_STR(1.N.M)" ...'
# and we need shell to process quotes!
$CC $CFLAGS $1 "$tempname".c -o "$tempname" >/dev/null 2>&1
r=$?
rm -f "$tempname" "$tempname".c "$tempname".o
return $r
}
check_libc_is_glibc() {
local tempname="$(mktemp)"
local r
echo "\
#include <stdlib.h>
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
@@ -66,12 +70,10 @@ check_libc_is_glibc() {
syntax error here
#endif
" >"$tempname".c
if $CC $CPPFLAGS $CFLAGS "$tempname".c -c -o "$tempname".o >/dev/null 2>&1; then
echo "$2";
else
echo "$1";
fi
rm -f "$tempname" "$tempname".[co]
! $CC $CFLAGS "$tempname".c -c -o "$tempname".o >/dev/null 2>&1
r=$?
rm -f "$tempname" "$tempname".c "$tempname".o
return $r
}
EXE="$1"
@@ -83,32 +85,41 @@ A_FILES="$6"
LDLIBS="$7"
# The --sort-section option is not supported by older versions of ld
SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""`
SORT_SECTION="-Wl,--sort-section,alignment"
if ! check_cc "-Wl,--sort-section,alignment"; then
echo "Your linker does not support --sort-section,alignment"
SORT_SECTION=""
fi
START_GROUP="-Wl,--start-group"
END_GROUP="-Wl,--end-group"
INFO_OPTS="-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose"
# gold may not support --sort-common (yet)
SORT_COMMON=`check_cc "-Wl,--sort-common" ""`
SORT_COMMON="-Wl,--sort-common"
if ! check_cc "-Wl,--sort-common"; then
echo "Your linker does not support --sort-common"
SORT_COMMON=""
fi
# Static linking against glibc produces buggy executables
# (glibc does not cope well with ld --gc-sections).
# See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
# Note that glibc is unsuitable for static linking anyway.
# We are removing -Wl,--gc-sections from link command line.
GC_SECTIONS=`(
. ./.config
if test x"$CONFIG_STATIC" = x"y"; then
check_libc_is_glibc "" "-Wl,--gc-sections"
else
echo "-Wl,--gc-sections"
GC_SECTIONS="-Wl,--gc-sections"
if (. ./.config && test x"$CONFIG_STATIC" = x"y") then
if check_libc_is_glibc; then
echo "Static linking against glibc, can't use --gc-sections"
GC_SECTIONS=""
fi
fi
)`
# The --gc-sections option is not supported by older versions of ld
if test -n "$GC_SECTIONS"; then
GC_SECTIONS=`check_cc "$GC_SECTIONS" ""`
if ! check_cc "$GC_SECTIONS"; then
echo "Your linker does not support $GC_SECTIONS"
GC_SECTIONS=""
fi
fi
# Sanitize lib list (dups, extra spaces etc)
+36
View File
@@ -106,6 +106,42 @@ a/a:a
a:b
" ""
testing "glibc build sort" "sort -t. -k 1,1 -k 2n,2n -k 3 input" "\
GLIBC_2.1
GLIBC_2.1.1
GLIBC_2.2
GLIBC_2.2.1
GLIBC_2.10
GLIBC_2.20
GLIBC_2.21
" "\
GLIBC_2.21
GLIBC_2.1.1
GLIBC_2.2.1
GLIBC_2.2
GLIBC_2.20
GLIBC_2.10
GLIBC_2.1
" ""
testing "glibc build sort unique" "sort -u -t. -k 1,1 -k 2n,2n -k 3 input" "\
GLIBC_2.1
GLIBC_2.1.1
GLIBC_2.2
GLIBC_2.2.1
GLIBC_2.10
GLIBC_2.20
GLIBC_2.21
" "\
GLIBC_2.10
GLIBC_2.2.1
GLIBC_2.1.1
GLIBC_2.20
GLIBC_2.2
GLIBC_2.1
GLIBC_2.21
" ""
testing "sort -u should consider field only when discarding" "sort -u -k2 input" "\
a c
" "\
+23 -1
View File
@@ -7,7 +7,7 @@
. ./testing.sh
# testing "test name" "options" "expected result" "file input" "stdin"
# testing "test name" "commands" "expected result" "file input" "stdin"
# file input will be file called "input"
# test can create a file "actual" instead of writing to stdout
@@ -30,6 +30,28 @@ testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f
rmdir foo
rm foo.zip
# File containing some damaged encrypted stream
testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
"Archive: bad.zip
inflating: ]3j½r«IK-%Ix
unzip: corrupted data
unzip: inflate error
1
" \
"" "\
begin-base64 644 bad.zip
UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
====
"
rm *
# Clean up scratch directory.
cd ..