From: Tim Kientzle Date: Sat, 7 Feb 2015 21:32:58 +0000 (-0800) Subject: Issue 402: Failed to recognize empty dir name in lha/lzh file X-Git-Tag: v3.1.900a~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8a2e4d2e6b450a239bb8f9d74239fa434bf7d35;p=thirdparty%2Flibarchive.git Issue 402: Failed to recognize empty dir name in lha/lzh file When parsing a directory name, we checked for the name length being zero, but not for the first byte being a null byte. Add a similar check for the file case. --- diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index 572686ab8..f8e01af81 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -1194,13 +1194,15 @@ lha_read_file_extended_header(struct archive_read *a, struct lha *lha, archive_string_empty(&lha->filename); break; } + if (extdheader[0] == '\0') + goto invalid; archive_strncpy(&lha->filename, (const char *)extdheader, datasize); break; case EXT_DIRECTORY: - if (datasize == 0) + if (datasize == 0 || extdheader[0] == '\0') /* no directory name data. exit this case. */ - break; + goto invalid; archive_strncpy(&lha->dirname, (const char *)extdheader, datasize);