diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-11-27 11:26:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-11-27 11:26:48 +0100 |
commit | f4fc303e3679e4ab0d45f60c31f9b687f27f7452 (patch) | |
tree | c270be417b97696e3a9897eab5602ce30faf313d | |
parent | 2d217799e8f23514ad3be6a951aa928c265bc6a4 (diff) | |
download | busybox-w32-f4fc303e3679e4ab0d45f60c31f9b687f27f7452.tar.gz busybox-w32-f4fc303e3679e4ab0d45f60c31f9b687f27f7452.tar.bz2 busybox-w32-f4fc303e3679e4ab0d45f60c31f9b687f27f7452.zip |
tar: fix too eager autodetection, closes 11531
function old new delta
is_suffixed_with - 54 +54
tar_main 1006 1026 +20
open_transformer 92 79 -13
config_file_action 478 458 -20
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 74/-33) Total: 41 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/libarchive/open_transformer.c | 3 | ||||
-rw-r--r-- | archival/tar.c | 8 | ||||
-rw-r--r-- | modutils/modprobe.c | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c index 9fefd4aad..4a4bf3916 100644 --- a/archival/libarchive/open_transformer.c +++ b/archival/libarchive/open_transformer.c | |||
@@ -278,8 +278,7 @@ static transformer_state_t *open_transformer(const char *fname, int fail_if_not_ | |||
278 | 278 | ||
279 | if (ENABLE_FEATURE_SEAMLESS_LZMA) { | 279 | if (ENABLE_FEATURE_SEAMLESS_LZMA) { |
280 | /* .lzma has no header/signature, can only detect it by extension */ | 280 | /* .lzma has no header/signature, can only detect it by extension */ |
281 | char *sfx = strrchr(fname, '.'); | 281 | if (is_suffixed_with(fname, ".lzma")) { |
282 | if (sfx && strcmp(sfx+1, "lzma") == 0) { | ||
283 | xstate = xzalloc(sizeof(*xstate)); | 282 | xstate = xzalloc(sizeof(*xstate)); |
284 | xstate->src_fd = fd; | 283 | xstate->src_fd = fd; |
285 | xstate->xformer = unpack_lzma_stream; | 284 | xstate->xformer = unpack_lzma_stream; |
diff --git a/archival/tar.c b/archival/tar.c index 1c71f7f66..6950c271d 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -1162,8 +1162,16 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1162 | tar_handle->seek = seek_by_read; | 1162 | tar_handle->seek = seek_by_read; |
1163 | } else | 1163 | } else |
1164 | if (ENABLE_FEATURE_TAR_AUTODETECT | 1164 | if (ENABLE_FEATURE_TAR_AUTODETECT |
1165 | && ENABLE_FEATURE_SEAMLESS_LZMA | ||
1165 | && flags == O_RDONLY | 1166 | && flags == O_RDONLY |
1166 | && !(opt & OPT_ANY_COMPRESS) | 1167 | && !(opt & OPT_ANY_COMPRESS) |
1168 | && is_suffixed_with(tar_filename, ".lzma") | ||
1169 | /* We do this only for .lzma files, they have no signature. | ||
1170 | * All other compression formats are recognized in | ||
1171 | * get_header_tar() when first tar block has invalid format. | ||
1172 | * Doing it here for all filenames would falsely trigger | ||
1173 | * on e.g. tarball with 1st file named "BZh5". | ||
1174 | */ | ||
1167 | ) { | 1175 | ) { |
1168 | tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0); | 1176 | tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0); |
1169 | if (tar_handle->src_fd < 0) | 1177 | if (tar_handle->src_fd < 0) |
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 59f6d54f3..291e4cb90 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -245,7 +245,7 @@ static int FAST_FUNC config_file_action(const char *filename, | |||
245 | parser_t *p; | 245 | parser_t *p; |
246 | struct module_entry *m; | 246 | struct module_entry *m; |
247 | int rc = TRUE; | 247 | int rc = TRUE; |
248 | const char *base, *ext; | 248 | const char *base; |
249 | 249 | ||
250 | /* Skip files that begin with a "." */ | 250 | /* Skip files that begin with a "." */ |
251 | base = bb_basename(filename); | 251 | base = bb_basename(filename); |
@@ -266,8 +266,7 @@ static int FAST_FUNC config_file_action(const char *filename, | |||
266 | * "include FILE_NOT_ENDING_IN_CONF" must work too. | 266 | * "include FILE_NOT_ENDING_IN_CONF" must work too. |
267 | */ | 267 | */ |
268 | if (depth != 0) { | 268 | if (depth != 0) { |
269 | ext = strrchr(base, '.'); | 269 | if (!is_suffixed_with(base, ".conf")) |
270 | if (ext == NULL || strcmp(ext + 1, "conf")) | ||
271 | goto error; | 270 | goto error; |
272 | } | 271 | } |
273 | 272 | ||