24838001ad9afefe88b1c0807be2fe4fc1d34aee
[openwrt/staging/stintel.git] / package / utils / busybox / patches / 007-upstream_zcat_no_ext_fix.patch
1 From 28dd64a0e1a9cffcde7799f2849b66c0e16bb9cc Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Fri, 10 Jan 2014 14:06:57 +0100
4 Subject: [PATCH] libarchive: open_zipped() does not need to check extensions
5 for e.g. gzip
6
7 We only need to check for signature-less extensions,
8 currently only .lzma. The rest can be happily autodetected.
9
10 This fixes "zcat FILE_WITHOUT_GZ_EXT" case, among others.
11
12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
13 (cherry picked from commit 7c47b560a8fc97956dd8132bd7f1863d83c19866)
14 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 ---
16 archival/libarchive/open_transformer.c | 23 +++++++++++------------
17 1 file changed, 11 insertions(+), 12 deletions(-)
18
19 --- a/archival/libarchive/open_transformer.c
20 +++ b/archival/libarchive/open_transformer.c
21 @@ -182,27 +182,26 @@ int FAST_FUNC setup_unzip_on_fd(int fd,
22
23 int FAST_FUNC open_zipped(const char *fname)
24 {
25 - char *sfx;
26 int fd;
27
28 fd = open(fname, O_RDONLY);
29 if (fd < 0)
30 return fd;
31
32 - sfx = strrchr(fname, '.');
33 - if (sfx) {
34 - sfx++;
35 - if (ENABLE_FEATURE_SEAMLESS_LZMA && strcmp(sfx, "lzma") == 0)
36 - /* .lzma has no header/signature, just trust it */
37 + if (ENABLE_FEATURE_SEAMLESS_LZMA) {
38 + /* .lzma has no header/signature, can only detect it by extension */
39 + char *sfx = strrchr(fname, '.');
40 + if (sfx && strcmp(sfx+1, "lzma") == 0) {
41 open_transformer_with_sig(fd, unpack_lzma_stream, "unlzma");
42 - else
43 - if ((ENABLE_FEATURE_SEAMLESS_GZ && strcmp(sfx, "gz") == 0)
44 - || (ENABLE_FEATURE_SEAMLESS_BZ2 && strcmp(sfx, "bz2") == 0)
45 - || (ENABLE_FEATURE_SEAMLESS_XZ && strcmp(sfx, "xz") == 0)
46 - ) {
47 - setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
48 + return fd;
49 }
50 }
51 + if ((ENABLE_FEATURE_SEAMLESS_GZ)
52 + || (ENABLE_FEATURE_SEAMLESS_BZ2)
53 + || (ENABLE_FEATURE_SEAMLESS_XZ)
54 + ) {
55 + setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
56 + }
57
58 return fd;
59 }