]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Increase the size of buff by 1 and adjust the readlink(2) call to
authorNgie Cooper <yanegomi@gmail.com>
Sun, 11 Dec 2016 00:15:18 +0000 (16:15 -0800)
committerNgie Cooper <yanegomi@gmail.com>
Sun, 11 Dec 2016 00:15:18 +0000 (16:15 -0800)
subtract the buffer len by 1 to account for the needed space for a
NUL terminator, as readlink isn't guaranteed to provide one

Reported by: Coverity
CID: 13312931332105

tar/test/main.c

index 71a0c49e5e4f95092f1cc28a054df63dda2db89a..6077af5f0217c8c3d1d51845dbd8896e557ac2bf 100644 (file)
@@ -1590,7 +1590,7 @@ is_symlink(const char *file, int line,
         * really not much point in bothering with this. */
        return (0);
 #else
-       char buff[300];
+       char buff[301];
        struct stat st;
        ssize_t linklen;
        int r;
@@ -1607,7 +1607,7 @@ is_symlink(const char *file, int line,
                return (0);
        if (contents == NULL)
                return (1);
-       linklen = readlink(pathname, buff, sizeof(buff));
+       linklen = readlink(pathname, buff, sizeof(buff) - 1);
        if (linklen < 0) {
                failure_start(file, line, "Can't read symlink %s", pathname);
                failure_finish(NULL);