]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
fix out of bounds read on empty string () filename for guntar, pax and v7tar 1066/head
authorYoung_X <YangX92@hotmail.com>
Tue, 18 Sep 2018 12:18:08 +0000 (20:18 +0800)
committerYoung_X <YangX92@hotmail.com>
Tue, 18 Sep 2018 12:18:08 +0000 (20:18 +0800)
libarchive/archive_write_set_format_gnutar.c
libarchive/archive_write_set_format_pax.c
libarchive/archive_write_set_format_v7tar.c

index 1d635d2dc3dc8f0bf957b1e4060320d5c1cbdbad..d9e41991196b9667791640d75643fac5c81e50f1 100644 (file)
@@ -339,7 +339,7 @@ archive_write_gnutar_header(struct archive_write *a,
                 * case getting WCS failed. On POSIX, this is a
                 * normal operation.
                 */
-               if (p != NULL && p[strlen(p) - 1] != '/') {
+               if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
                        struct archive_string as;
 
                        archive_string_init(&as);
index 6f7fe7839001deef476142456cafda2927d08443..b5b7b7483c1f6ecd54d957ff5b705e2acd3a7c22 100644 (file)
@@ -579,7 +579,7 @@ archive_write_pax_header(struct archive_write *a,
                         * case getting WCS failed. On POSIX, this is a
                         * normal operation.
                         */
-                       if (p != NULL && p[strlen(p) - 1] != '/') {
+                       if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
                                struct archive_string as;
 
                                archive_string_init(&as);
index 17efbaf753f835abd768041ad0cb6e65ee545f04..2afcc92d5fa2b49034f5e5f0dce8769580b43f2d 100644 (file)
@@ -285,7 +285,7 @@ archive_write_v7tar_header(struct archive_write *a, struct archive_entry *entry)
                 * case getting WCS failed. On POSIX, this is a
                 * normal operation.
                 */
-               if (p != NULL && p[strlen(p) - 1] != '/') {
+               if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
                        struct archive_string as;
 
                        archive_string_init(&as);