summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2010-01-23 07:54:15 +0000
committerkientzle <kientzle@FreeBSD.org>2010-01-23 07:54:15 +0000
commit5d107439deae02e9b85a93cfb675e9e8ecf163fa (patch)
tree3f3ba9c86a85a746debdf4d565d92e5972f137d4 /lib/libarchive
parent5d7561656a2ec6b5511fb174aaef518d2e64eebe (diff)
downloadFreeBSD-src-5d107439deae02e9b85a93cfb675e9e8ecf163fa.zip
FreeBSD-src-5d107439deae02e9b85a93cfb675e9e8ecf163fa.tar.gz
If we can't stat a file, return the correct ARCHIVE_FAILED (this entry can't
be processed any further) and a suitable error string. In particular, this improves the error-reporting when cpio -o is given a nonexistent filename.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read_disk_entry_from_file.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/libarchive/archive_read_disk_entry_from_file.c b/lib/libarchive/archive_read_disk_entry_from_file.c
index a833765..dbb7d75 100644
--- a/lib/libarchive/archive_read_disk_entry_from_file.c
+++ b/lib/libarchive/archive_read_disk_entry_from_file.c
@@ -121,18 +121,27 @@ archive_read_disk_entry_from_file(struct archive *_a,
*/
#if HAVE_FSTAT
if (fd >= 0) {
- if (fstat(fd, &s) != 0)
- return (ARCHIVE_FATAL);
+ if (fstat(fd, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't fstat");
+ return (ARCHIVE_FAILED);
+ }
} else
#endif
#if HAVE_LSTAT
if (!a->follow_symlinks) {
- if (lstat(path, &s) != 0)
- return (ARCHIVE_FATAL);
+ if (lstat(path, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't lstat %s", path);
+ return (ARCHIVE_FAILED);
+ }
} else
#endif
- if (stat(path, &s) != 0)
- return (ARCHIVE_FATAL);
+ if (stat(path, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't stat %s", path);
+ return (ARCHIVE_FAILED);
+ }
st = &s;
}
archive_entry_copy_stat(entry, st);
@@ -159,7 +168,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
if (lnklen < 0) {
archive_set_error(&a->archive, errno,
"Couldn't read link data");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
linkbuffer[lnklen] = 0;
archive_entry_set_symlink(entry, linkbuffer);
OpenPOWER on IntegriCloud