]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Skip root directory symlink check
authorAndrew Gregory <andrew.gregory.8@gmail.com>
Fri, 15 Jan 2016 07:39:41 +0000 (02:39 -0500)
committerAndrew Gregory <andrew.gregory.8@gmail.com>
Tue, 23 Feb 2016 04:23:23 +0000 (23:23 -0500)
The first time check_symlinks is called on an absolute path it will use
the entry pathname directly, blanking the leading slash.  This leads to
calling lstat on an empty string, which returns ENOENT, terminating the
loop early and falsely marking the path as safe.

libarchive/archive_write_disk_posix.c

index 1eb0e91d71dcdba268e0560245a149a8eedf0b34..6737cd755b226f7a06b69f637bba3da3648dcb37 100644 (file)
@@ -2386,6 +2386,9 @@ check_symlinks(struct archive_write_disk *a)
                while ((*pn != '\0') && (*p == *pn))
                        ++p, ++pn;
        }
+       /* Skip the root directory if the path is absolute. */
+       if(pn == a->name && pn[0] == '/')
+               ++pn;
        c = pn[0];
        /* Keep going until we've checked the entire name. */
        while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) {