]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Return ARCHIVE_WARN properly if large inode number was truncated.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 8 Nov 2009 18:36:26 +0000 (13:36 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 8 Nov 2009 18:36:26 +0000 (13:36 -0500)
Found by Clang Static Analyzer.

SVN-Revision: 1594

libarchive/archive_write_set_format_cpio.c

index d6090a6b7ddd178abc3eb11bb09c57b599db42e8..c293ef2dbad3404e2b84f4264cec77584962922e 100644 (file)
@@ -108,12 +108,12 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
 {
        struct cpio *cpio;
        const char *p, *path;
-       int pathlength, ret;
+       int pathlength, ret, ret2;
        int64_t ino;
        struct cpio_header       h;
 
        cpio = (struct cpio *)a->format_data;
-       ret = 0;
+       ret2 = ARCHIVE_OK;
 
        path = archive_entry_pathname(entry);
        pathlength = strlen(path) + 1; /* Include trailing null. */
@@ -130,7 +130,7 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
        if (ino < 0 || ino > 0777777) {
                archive_set_error(&a->archive, ERANGE,
                    "large inode number truncated");
-               ret = ARCHIVE_WARN;
+               ret2 = ARCHIVE_WARN;
        }
 
        format_octal(archive_entry_ino64(entry) & 0777777, &h.c_ino, sizeof(h.c_ino));
@@ -172,6 +172,8 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
        if (p != NULL  &&  *p != '\0')
                ret = (a->compressor.write)(a, p, strlen(p));
 
+       if (ret == ARCHIVE_OK)
+               ret = ret2;
        return (ret);
 }