Use more accurate bzip2 patch detection

The existing code only checks for 'BZ' at the start of the file,
which has an unfortunate overlap with BugZilla, and thus is
quite possible to be at the start of a standard patch.

Instead check for 'BZh' at the start, which is what file(1) does.
This commit is contained in:
Pádraig Brady 2015-02-17 16:30:00 +00:00 committed by Florian Festi
parent 2d418ad3c1
commit f793add4ae
1 changed files with 2 additions and 1 deletions

View File

@ -339,7 +339,8 @@ int rpmFileIsCompressed(const char * file, rpmCompressedMagic * compressed)
rc = 0; rc = 0;
if ((magic[0] == 'B') && (magic[1] == 'Z')) { if ((magic[0] == 'B') && (magic[1] == 'Z') &&
(magic[2] == 'h')) {
*compressed = COMPRESSED_BZIP2; *compressed = COMPRESSED_BZIP2;
} else if ((magic[0] == 'P') && (magic[1] == 'K') && } else if ((magic[0] == 'P') && (magic[1] == 'K') &&
(((magic[2] == 3) && (magic[3] == 4)) || (((magic[2] == 3) && (magic[3] == 4)) ||