FIX CPIO SYMLINK/HARDLINK BUG
authorGuy Harris <guy@auspex.com>
Sun, 16 Aug 1992 00:00:00 +0000 (00:00 +0000)
committerGuy Harris <guy@auspex.com>
Sun, 16 Aug 1992 00:00:00 +0000 (00:00 +0000)
The "cpio" program has a bug which tells it to make hard links
to symlinks that results in hard links being made to the target of the
symlink, even if it's a directory, if you have permission to do so.

AUTHOR: Guy Harris (guy@auspex.com)
386BSD-Patchkit: patch00048

usr/src/usr.bin/cpio/cpio.c

index 5c7d865..817e0ac 100644 (file)
        Reworked cpio which uses getopt(3) to interpret flag arguments and
        changes reels to the save file name.
        Performance and size improvements.
        Reworked cpio which uses getopt(3) to interpret flag arguments and
        changes reels to the save file name.
        Performance and size improvements.
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00048
+ * --------------------         -----   ----------------------
+ *
+ * 16 Aug 92   Guy Harris              Symbolic link fix
 */
 
 /*     cpio    COMPILE:        cc -O cpio.c -s -i -o cpio -lgen -lerr
 */
 
 /*     cpio    COMPILE:        cc -O cpio.c -s -i -o cpio -lgen -lerr
@@ -488,7 +495,8 @@ char **argv;
                                i++;
                        strcpy(fullp, &(Hdr.h_name[i]));
 
                                i++;
                        strcpy(fullp, &(Hdr.h_name[i]));
 
-                       if( PassLink  &&  !A_directory  &&  Dev == Statb.st_dev ) {
+/* 16 Aug 92*/         if( PassLink  &&  !A_directory  &&  !A_symlink
+                           &&  Dev == Statb.st_dev ) {
                                if(link(Hdr.h_name, Fullname) < 0) {
                                        switch(errno) {
                                                case ENOENT:
                                if(link(Hdr.h_name, Fullname) < 0) {
                                        switch(errno) {
                                                case ENOENT: