diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-01-27 16:11:46 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-01-27 16:11:46 +0200 |
commit | a0a972702a940175b3c3ca2491c6e4d0a9461e63 (patch) | |
tree | 471ed7b72a8d1ab10fca13101c163713b08ccc7c /rpmio | |
parent | c693169deeabf8f9a65a824699cc0c98cedd491f (diff) | |
download | rpm-a0a972702a940175b3c3ca2491c6e4d0a9461e63.tar.gz rpm-a0a972702a940175b3c3ca2491c6e4d0a9461e63.tar.bz2 rpm-a0a972702a940175b3c3ca2491c6e4d0a9461e63.zip |
Detect lzma magic if it exists, otherwise dumb check for .lzma filename
- Newer lzma-utils make a magic header in archives, current stable versions
don't. Guessing based on common compression flags used by current lzma
versions is feeble and futile...
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/rpmfileutil.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index e3ff9eee6..32e95a6c7 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -404,12 +404,11 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed) } else if ((magic[0] == 0120) && (magic[1] == 0113) && (magic[2] == 0003) && (magic[3] == 0004)) { /* pkzip */ *compressed = COMPRESSED_ZIP; - } else if ((magic[ 9] == 0x00) && (magic[10] == 0x00) && - (magic[11] == 0x00) && (magic[12] == 0x00)) { - /* lzma */ - /* FIXME: lzma doesn't have a magic, - * consider to additionally check the filename */ - *compressed = COMPRESSED_LZMA; + } else if ((magic[0] == 0xff) && (magic[1] == 0x4c) && + (magic[2] == 0x5a) && (magic[3] == 0x4d) && + (magic[4] == 0x41) && (magic[5] == 0x00)) { + /* new style lzma with magic */ + *compressed = COMPRESSED_LZMA; } else if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */ ((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */ ((magic[0] == 0037) && (magic[1] == 0036)) || /* pack */ @@ -417,6 +416,8 @@ int isCompressed(const char * file, rpmCompressedMagic * compressed) ((magic[0] == 0037) && (magic[1] == 0235)) /* compress */ ) { *compressed = COMPRESSED_OTHER; + } else if (rpmFileHasSuffix(file, ".lzma")) { + *compressed = COMPRESSED_LZMA; } return rc; |