]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix a long standing bug that archive_write_add_filter_program
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 7 Oct 2012 02:03:48 +0000 (11:03 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 7 Oct 2012 02:03:48 +0000 (11:03 +0900)
incorrectly handles the return value of __archive_write_filter().

libarchive/archive_write_add_filter_program.c

index 149a211b644823dcb9164cda29526de78d6d13e8..3dda6bae0b62a657d24e584bce7bd163e965820f 100644 (file)
@@ -344,14 +344,9 @@ child_write(struct archive_write_filter *f, const char *buf, size_t buf_len)
 
                ret = __archive_write_filter(f->next_filter,
                    data->child_buf, data->child_buf_avail);
-               if (ret <= 0)
+               if (ret != ARCHIVE_OK)
                        return (-1);
-
-               if ((size_t)ret < data->child_buf_avail) {
-                       memmove(data->child_buf, data->child_buf + ret,
-                           data->child_buf_avail - ret);
-               }
-               data->child_buf_avail -= ret;
+               data->child_buf_avail = 0;
        }
 }