Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e50f74da70 | ||
|
|
9de318d63e | ||
|
|
be729c1d3b | ||
|
|
092fabcf1d | ||
|
|
6767af17f1 | ||
|
|
5c23f2566c |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 24
|
||||
SUBLEVEL = 0
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
@@ -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
@@ -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 ..
|
||||
|
||||
Reference in new issue
Block a user