]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Check the position before dereferencing the pointer.
authorTim Kientzle <kientzle@gmail.com>
Thu, 17 Nov 2011 05:38:07 +0000 (00:38 -0500)
committerTim Kientzle <kientzle@gmail.com>
Thu, 17 Nov 2011 05:38:07 +0000 (00:38 -0500)
This avoids dereferencing one byte past the end of a string.

SVN-Revision: 3799

libarchive/archive_string.c

index 4e57d62e1383281067bc38dd193d6fa482e32405..95bed6eda39b5aa25ffdb58e4bbbba7d3f786a24 100644 (file)
@@ -152,7 +152,7 @@ __archive_strncat(struct archive_string *as, const void *_p, size_t n)
        /* Like strlen(p), except won't examine positions beyond p[n]. */
        s = 0;
        pp = p;
-       while (*pp && s < n) {
+       while (s < n && *pp) {
                pp++;
                s++;
        }