]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 402: Failed to recognize empty dir name in lha/lzh file
authorTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 21:32:58 +0000 (13:32 -0800)
committerTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 21:32:58 +0000 (13:32 -0800)
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.

libarchive/archive_read_support_format_lha.c

index 572686ab84e972f2c93e4e7978a4b44debf068fe..f8e01af8115b9d0ca50f43821267c8bc0dfdf057 100644 (file)
@@ -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);