Author: kientzle
Date: Sat Jan 23 07:54:15 2010
New Revision: 202871
URL: http://svn.freebsd.org/changeset/base/202871

Log:
  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.

Modified:
  head/lib/libarchive/archive_read_disk_entry_from_file.c

Modified: head/lib/libarchive/archive_read_disk_entry_from_file.c
==============================================================================
--- head/lib/libarchive/archive_read_disk_entry_from_file.c     Sat Jan 23 
07:54:06 2010        (r202870)
+++ head/lib/libarchive/archive_read_disk_entry_from_file.c     Sat Jan 23 
07:54:15 2010        (r202871)
@@ -121,18 +121,27 @@ archive_read_disk_entry_from_file(struct
                 */
 #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
                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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to