Ticket #1748: lzma archives with .tlz extention are not recognized as archives

Attempting to open a .tlz lzma archive fails - error 'xxx.tlz doesn't look like a tar archive'.
If the file is renamed to .tar.lzma, it is opened without problems.

Fix issue: add recognize of '.tlz' extention.

Refactoring: avoid calls of strlen() function

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-10-28 00:51:39 +02:00
parent 9c854e73d4
commit 575f996e0d

View File

@ -861,6 +861,7 @@ enum compression_type
get_compression_type (int fd, const char * name)
{
unsigned char magic[16];
size_t str_len;
/* Read the magic signature */
if (mc_read (fd, (char *) magic, 4) != 4)
@ -937,8 +938,10 @@ get_compression_type (int fd, const char * name)
}
}
str_len = strlen(name);
/* HACK: we must belive to extention of LZMA file :) ...*/
if (strlen(name) > 5 && strcmp(&name[strlen(name)-5],".lzma") == 0)
if ( (str_len > 5 && strcmp(&name[str_len-5],".lzma") == 0) ||
(str_len > 4 && strcmp(&name[str_len-4],".tlz") == 0))
return COMPRESSION_LZMA;
return COMPRESSION_NONE;