Compare commits

...
Author SHA1 Message Date
Denys Vlasenko 28dd64a0e1 libarchive: open_zipped() does not need to check extensions for e.g. gzip
We only need to check for signature-less extensions,
currently only .lzma. The rest can be happily autodetected.

This fixes "zcat FILE_WITHOUT_GZ_EXT" case, among others.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
(cherry picked from commit 7c47b560a8)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-10-21 15:11:54 -04:00
Denys Vlasenko 5698ff9323 lzop: add overflow check
See CVE-2014-4607
http://www.openwall.com/lists/oss-security/2014/06/26/20

function                                             old     new   delta
lzo1x_decompress_safe                               1010    1031     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(cherry picked from commit a9dc7c2f59)
2014-10-21 08:41:37 -04:00
Denys Vlasenko d9e0c438e1 Apply post-1.22.0 patches, bump version to 1.22.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-20 03:41:48 +01:00
9 changed files with 78 additions and 17 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 22
SUBLEVEL = 0
SUBLEVEL = 1
EXTRAVERSION =
NAME = Unnamed
+2
View File
@@ -76,11 +76,13 @@
# define TEST_IP (ip < ip_end)
# define NEED_IP(x) \
if ((unsigned)(ip_end - ip) < (unsigned)(x)) goto input_overrun
# define TEST_IV(x) if ((x) > (unsigned)0 - (511)) goto input_overrun
# undef TEST_OP /* don't need both of the tests here */
# define TEST_OP 1
# define NEED_OP(x) \
if ((unsigned)(op_end - op) < (unsigned)(x)) goto output_overrun
# define TEST_OV(x) if ((x) > (unsigned)0 - (511)) goto output_overrun
#define HAVE_ANY_OP 1
+3
View File
@@ -92,6 +92,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
ip++;
NEED_IP(1);
}
TEST_IV(t);
t += 15 + *ip++;
}
/* copy literals */
@@ -224,6 +225,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
ip++;
NEED_IP(1);
}
TEST_IV(t);
t += 31 + *ip++;
}
#if defined(COPY_DICT)
@@ -265,6 +267,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
ip++;
NEED_IP(1);
}
TEST_IV(t);
t += 7 + *ip++;
}
#if defined(COPY_DICT)
+11 -12
View File
@@ -182,27 +182,26 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
int FAST_FUNC open_zipped(const char *fname)
{
char *sfx;
int fd;
fd = open(fname, O_RDONLY);
if (fd < 0)
return fd;
sfx = strrchr(fname, '.');
if (sfx) {
sfx++;
if (ENABLE_FEATURE_SEAMLESS_LZMA && strcmp(sfx, "lzma") == 0)
/* .lzma has no header/signature, just trust it */
if (ENABLE_FEATURE_SEAMLESS_LZMA) {
/* .lzma has no header/signature, can only detect it by extension */
char *sfx = strrchr(fname, '.');
if (sfx && strcmp(sfx+1, "lzma") == 0) {
open_transformer_with_sig(fd, unpack_lzma_stream, "unlzma");
else
if ((ENABLE_FEATURE_SEAMLESS_GZ && strcmp(sfx, "gz") == 0)
|| (ENABLE_FEATURE_SEAMLESS_BZ2 && strcmp(sfx, "bz2") == 0)
|| (ENABLE_FEATURE_SEAMLESS_XZ && strcmp(sfx, "xz") == 0)
) {
setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
return fd;
}
}
if ((ENABLE_FEATURE_SEAMLESS_GZ)
|| (ENABLE_FEATURE_SEAMLESS_BZ2)
|| (ENABLE_FEATURE_SEAMLESS_XZ)
) {
setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
}
return fd;
}
+20 -1
View File
@@ -1291,9 +1291,27 @@ int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int find_main(int argc UNUSED_PARAM, char **argv)
{
int i, firstopt, status = EXIT_SUCCESS;
char **past_HLP, *saved;
INIT_G();
/* "find -type f" + getopt("+HLP") => disaster.
* Need to avoid getopt running into a non-HLP option.
* Do this by temporarily storing NULL there:
*/
past_HLP = argv;
for (;;) {
saved = *++past_HLP;
if (!saved)
break;
if (saved[0] != '-')
break;
if (!saved[1])
break; /* it is "-" */
if ((saved+1)[strspn(saved+1, "HLP")] != '\0')
break;
}
*past_HLP = NULL;
/* "+": stop on first non-option */
i = getopt32(argv, "+HLP");
if (i & (1<<0))
@@ -1301,7 +1319,8 @@ int find_main(int argc UNUSED_PARAM, char **argv)
if (i & (1<<1))
G.recurse_flags |= ACTION_FOLLOWLINKS | ACTION_DANGLING_OK;
/* -P is default and is ignored */
argv += optind;
argv = past_HLP; /* same result as "argv += optind;" */
*past_HLP = saved;
for (firstopt = 0; argv[firstopt]; firstopt++) {
if (argv[firstopt][0] == '-')
+25 -3
View File
@@ -373,6 +373,9 @@ static int grep_file(FILE *file)
opt_f_not_found: ;
}
} else {
#if ENABLE_EXTRA_COMPAT
unsigned start_pos;
#endif
char *match_at;
if (!(gl->flg_mem_alocated_compiled & COMPILED)) {
@@ -389,15 +392,18 @@ static int grep_file(FILE *file)
#if !ENABLE_EXTRA_COMPAT
gl->matched_range.rm_so = 0;
gl->matched_range.rm_eo = 0;
#else
start_pos = 0;
#endif
match_at = line;
opt_w_again:
//bb_error_msg("'%s' start_pos:%d line_len:%d", match_at, start_pos, line_len);
if (
#if !ENABLE_EXTRA_COMPAT
regexec(&gl->compiled_regex, match_at, 1, &gl->matched_range, 0) == 0
#else
re_search(&gl->compiled_regex, match_at, line_len,
/*start:*/ 0, /*range:*/ line_len,
start_pos, /*range:*/ line_len,
&gl->matched_range) >= 0
#endif
) {
@@ -416,8 +422,24 @@ static int grep_file(FILE *file)
if (!c || (!isalnum(c) && c != '_')) {
found = 1;
} else {
match_at += gl->matched_range.rm_eo;
goto opt_w_again;
/*
* Why check gl->matched_range.rm_eo?
* Zero-length match makes -w skip the line:
* "echo foo | grep ^" prints "foo",
* "echo foo | grep -w ^" prints nothing.
* Without such check, we can loop forever.
*/
#if !ENABLE_EXTRA_COMPAT
if (gl->matched_range.rm_eo != 0) {
match_at += gl->matched_range.rm_eo;
goto opt_w_again;
}
#else
if (gl->matched_range.rm_eo > start_pos) {
start_pos = gl->matched_range.rm_eo;
goto opt_w_again;
}
#endif
}
}
}
+2
View File
@@ -1255,7 +1255,9 @@ line_input_t* FAST_FUNC new_line_input_t(int flags)
{
line_input_t *n = xzalloc(sizeof(*n));
n->flags = flags;
#if MAX_HISTORY > 0
n->max_history = MAX_HISTORY;
#endif
return n;
}
+2
View File
@@ -1445,6 +1445,8 @@ update_local_clock(peer_t *p)
run_script("step", offset);
recv_time += offset;
#if USING_INITIAL_FREQ_ESTIMATION
if (G.discipline_state == STATE_NSET) {
set_new_values(STATE_FREQ, /*offset:*/ 0, recv_time);
+12
View File
@@ -147,6 +147,18 @@ testing "grep -w doesn't stop on 1st mismatch" \
"foop foo\n" \
""
testing "grep -w ^str doesn't match str not at the beginning" \
"grep -w ^str input" \
"" \
"strstr\n" \
""
testing "grep -w ^ doesn't hang" \
"grep -w ^ input" \
"" \
"anything\n" \
""
# 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