* Fixed a small bug that could cause tar to emit warning messages
authorEric Andersen <andersen@codepoet.org>
Fri, 9 Jun 2000 20:51:50 +0000 (20:51 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 9 Jun 2000 20:51:50 +0000 (20:51 -0000)
    and not extract the first file in a directory in some cases
    of nested directories.  Thanks to Kevin Traas <kevin@netmaster.com>
    for helping track this one down.
 -Erik

Changelog
archival/tar.c
tar.c

index 98d145f0b0486b378f7ec6f9ea48c85cc003a533..30f28209d8f93e6edaed659bc312c0ae3bea6a5b 100644 (file)
--- a/Changelog
+++ b/Changelog
            Pavel Roskin
        * Syslogd will not go to background if "-n" is given. Better help
            and argument checking -- Pavel Roskin
+       * Fixed a small bug that could cause tar to emit warning messages
+           and not extract the first file in a directory in some cases
+           of nested directories.  Thanks to Kevin Traas <kevin@netmaster.com>
+           for helping track this one down.
        * More doc updates
 
 
index 7d440f451c7c51ac426751100e8bc0c3a9976cd5..86f996576d8848b336f554ab3f450e3566a1a158 100644 (file)
@@ -300,11 +300,14 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
 
        /* Open the file to be written, if a file is supposed to be written */
        if (extractFlag==TRUE && tostdoutFlag==FALSE) {
-               if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, header->mode & ~S_IFMT)) < 0)
-                       errorMsg(io_error, header->name, strerror(errno)); 
                /* Create the path to the file, just in case it isn't there...
                 * This should not screw up path permissions or anything. */
                createPath(header->name, 0777);
+               if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, 
+                                               header->mode & ~S_IFMT)) < 0) {
+                       errorMsg(io_error, header->name, strerror(errno)); 
+                       return( FALSE);
+               }
        }
 
        /* Write out the file, if we are supposed to be doing that */
diff --git a/tar.c b/tar.c
index 7d440f451c7c51ac426751100e8bc0c3a9976cd5..86f996576d8848b336f554ab3f450e3566a1a158 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -300,11 +300,14 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
 
        /* Open the file to be written, if a file is supposed to be written */
        if (extractFlag==TRUE && tostdoutFlag==FALSE) {
-               if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, header->mode & ~S_IFMT)) < 0)
-                       errorMsg(io_error, header->name, strerror(errno)); 
                /* Create the path to the file, just in case it isn't there...
                 * This should not screw up path permissions or anything. */
                createPath(header->name, 0777);
+               if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, 
+                                               header->mode & ~S_IFMT)) < 0) {
+                       errorMsg(io_error, header->name, strerror(errno)); 
+                       return( FALSE);
+               }
        }
 
        /* Write out the file, if we are supposed to be doing that */