From: Martin Matuska Date: Sun, 3 Feb 2019 22:47:42 +0000 (+0100) Subject: POSIX reader: more next_entry() fixes X-Git-Tag: v3.4.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=687420b567753b88bbd12b53a0853d78e681c50b;p=thirdparty%2Flibarchive.git POSIX reader: more next_entry() fixes - if not descending, fail if tree_current_lstat() returns ENOENT - fix the "File removed before we read it" error message if processing multiple files at a time. Fixes #1082 --- diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index e8bbcad3c..09c366f5f 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -889,12 +889,16 @@ next_entry(struct archive_read_disk *a, struct tree *t, case TREE_REGULAR: lst = tree_current_lstat(t); if (lst == NULL) { - if (errno == ENOENT) { + if (errno == ENOENT && t->depth > 0) { delayed = ARCHIVE_WARN; delayed_errno = errno; - archive_string_sprintf(&delayed_str, - "%s: File removed before we read it", - tree_current_path(t)); + if (delayed_str.length == 0) { + archive_string_sprintf(&delayed_str, + "%s", tree_current_path(t)); + } else { + archive_string_sprintf(&delayed_str, + " %s", tree_current_path(t)); + } } else { archive_set_error(&a->archive, errno, "%s: Cannot stat", @@ -1097,9 +1101,12 @@ next_entry(struct archive_read_disk *a, struct tree *t, if (r == ARCHIVE_OK) { r = delayed; - if (r != ARCHIVE_OK) + if (r != ARCHIVE_OK) { + archive_string_sprintf(&delayed_str, ": %s", + "File removed before we read it"); archive_set_error(&(a->archive), delayed_errno, "%s", delayed_str.s); + } } if (!archive_string_empty(&delayed_str)) archive_string_free(&delayed_str);