Lines 935-941
Link Here
|
935 |
enum compression_type |
935 |
enum compression_type |
936 |
get_compression_type (int fd) |
936 |
get_compression_type (int fd) |
937 |
{ |
937 |
{ |
938 |
unsigned char magic[4]; |
938 |
unsigned char magic[16]; |
939 |
|
939 |
|
940 |
/* Read the magic signature */ |
940 |
/* Read the magic signature */ |
941 |
if (mc_read (fd, (char *) magic, 4) != 4) |
941 |
if (mc_read (fd, (char *) magic, 4) != 4) |
Lines 979-984
Link Here
|
979 |
return COMPRESSION_BZIP2; |
979 |
return COMPRESSION_BZIP2; |
980 |
} |
980 |
} |
981 |
} |
981 |
} |
|
|
982 |
|
983 |
/* LZMA files; both LZMA_Alone and LZMA utils formats. The LZMA_Alone |
984 |
* format is used by the LZMA_Alone tool from LZMA SDK. The LZMA utils |
985 |
* format is the default format of LZMA utils 4.32.1 and later. */ |
986 |
if (magic[0] < 0xE1 || (magic[0] == 0xFF && magic[1] == 'L' && |
987 |
magic[2] == 'Z' && magic[3] == 'M')) { |
988 |
if (mc_read (fd, (char *) magic + 4, 9) == 9) { |
989 |
/* LZMA utils format */ |
990 |
if (magic[0] == 0xFF && magic[4] == 'A' && magic[5] == 0x00) |
991 |
return COMPRESSION_LZMA; |
992 |
/* The LZMA_Alone format has no magic bytes, thus we |
993 |
* need to play a wizard. This can give false positives, |
994 |
* thus the detection below should be removed when |
995 |
* the newer LZMA utils format has got popular. */ |
996 |
if (magic[0] < 0xE1 && magic[4] < 0x20 && |
997 |
((magic[10] == 0x00 && magic[11] == 0x00 && |
998 |
magic[12] == 0x00) || |
999 |
(magic[5] == 0xFF && magic[6] == 0xFF && |
1000 |
magic[7] == 0xFF && magic[8] == 0xFF && |
1001 |
magic[9] == 0xFF && magic[10] == 0xFF && |
1002 |
magic[11] == 0xFF && magic[12] == 0xFF))) |
1003 |
return COMPRESSION_LZMA; |
1004 |
} |
1005 |
} |
1006 |
|
982 |
return 0; |
1007 |
return 0; |
983 |
} |
1008 |
} |
984 |
|
1009 |
|
Lines 989-994
Link Here
|
989 |
case COMPRESSION_GZIP: return "#ugz"; |
1014 |
case COMPRESSION_GZIP: return "#ugz"; |
990 |
case COMPRESSION_BZIP: return "#ubz"; |
1015 |
case COMPRESSION_BZIP: return "#ubz"; |
991 |
case COMPRESSION_BZIP2: return "#ubz2"; |
1016 |
case COMPRESSION_BZIP2: return "#ubz2"; |
|
|
1017 |
case COMPRESSION_LZMA: return "#ulzma"; |
992 |
} |
1018 |
} |
993 |
/* Should never reach this place */ |
1019 |
/* Should never reach this place */ |
994 |
fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); |
1020 |
fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); |