mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Ticket #1798: Not enough magic read before checking for lzma files
In the function get_compression_type() in src/util.c, only 5 bytes of the file are read into the magic array, but the test for lzma files checks the first 6 bytes in the magic array. Fix issue: now reads 6 bytes for correct recognize LZMA-files. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
9736afb521
commit
c9978ff155
48
src/util.c
48
src/util.c
@ -909,34 +909,30 @@ get_compression_type (int fd, const char * name)
|
|||||||
/* Support for LZMA (only utils format with magic in header).
|
/* Support for LZMA (only utils format with magic in header).
|
||||||
* This is the default format of LZMA utils 4.32.1 and later. */
|
* This is the default format of LZMA utils 4.32.1 and later. */
|
||||||
|
|
||||||
if (mc_read(fd, (char *) magic+4, 1) == 1)
|
if (mc_read(fd, (char *) magic+4, 2) != 2)
|
||||||
{
|
return COMPRESSION_NONE;
|
||||||
/* LZMA utils format */
|
|
||||||
if
|
/* LZMA utils format */
|
||||||
( magic[0] == 0xFF
|
if (
|
||||||
&& magic[1] == 'L'
|
magic[0] == 0xFF
|
||||||
&& magic[2] == 'Z'
|
&& magic[1] == 'L'
|
||||||
&& magic[3] == 'M'
|
&& magic[2] == 'Z'
|
||||||
&& magic[4] == 'A'
|
&& magic[3] == 'M'
|
||||||
&& magic[5] == 0x00
|
&& magic[4] == 'A'
|
||||||
)
|
&& magic[5] == 0x00
|
||||||
return COMPRESSION_LZMA;
|
)
|
||||||
}
|
return COMPRESSION_LZMA;
|
||||||
|
|
||||||
/* XZ compression magic */
|
/* XZ compression magic */
|
||||||
if (mc_read(fd, (char *) magic+5, 1) == 1)
|
if (
|
||||||
{
|
magic[0] == 0xFD
|
||||||
if (
|
&& magic[1] == 0x37
|
||||||
magic[0] == 0xFD
|
&& magic[2] == 0x7A
|
||||||
&& magic[1] == 0x37
|
&& magic[3] == 0x58
|
||||||
&& magic[2] == 0x7A
|
&& magic[4] == 0x5A
|
||||||
&& magic[3] == 0x58
|
&& magic[5] == 0x00
|
||||||
&& magic[4] == 0x5A
|
)
|
||||||
&& magic[5] == 0x00
|
return COMPRESSION_XZ;
|
||||||
){
|
|
||||||
return COMPRESSION_XZ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
str_len = strlen(name);
|
str_len = strlen(name);
|
||||||
/* HACK: we must belive to extention of LZMA file :) ...*/
|
/* HACK: we must belive to extention of LZMA file :) ...*/
|
||||||
|
Loading…
Reference in New Issue
Block a user