From: Ngie Cooper Date: Sun, 11 Dec 2016 00:15:18 +0000 (-0800) Subject: Increase the size of buff by 1 and adjust the readlink(2) call to X-Git-Tag: v3.3.0~90^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7caec3e4cab2b1f16743c1df3e48d78a4daa4aa;p=thirdparty%2Flibarchive.git Increase the size of buff by 1 and adjust the readlink(2) call to 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: 1331293, 1332105 --- diff --git a/tar/test/main.c b/tar/test/main.c index 71a0c49e5..6077af5f0 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -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);