From f793add4ae429e11664b403df4c32a73bc31a6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 17 Feb 2015 16:30:00 +0000 Subject: [PATCH] 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. --- rpmio/rpmfileutil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index 5ea2f0940..40d619c29 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -339,7 +339,8 @@ int rpmFileIsCompressed(const char * file, rpmCompressedMagic * compressed) rc = 0; - if ((magic[0] == 'B') && (magic[1] == 'Z')) { + if ((magic[0] == 'B') && (magic[1] == 'Z') && + (magic[2] == 'h')) { *compressed = COMPRESSED_BZIP2; } else if ((magic[0] == 'P') && (magic[1] == 'K') && (((magic[2] == 3) && (magic[3] == 4)) ||