From 575f996e0dc535cdab8a2f68bc2670619fd8eef8 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 28 Oct 2009 00:51:39 +0200 Subject: [PATCH] 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 --- src/util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index e99d3503f..f1fa9b770 100644 --- a/src/util.c +++ b/src/util.c @@ -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;