11) removed silly debug message
authorewt <devnull@localhost>
Mon, 19 Feb 1996 23:34:25 +0000 (23:34 +0000)
committerewt <devnull@localhost>
Mon, 19 Feb 1996 23:34:25 +0000 (23:34 +0000)
2) fixed problem with unarchiving files containing shell globbing characters

CVS patchset: 332
CVS date: 1996/02/19 23:34:25

lib/install.c

index 448a95a..270a772 100644 (file)
@@ -96,6 +96,8 @@ int rpmInstallPackage(char * prefix, rpmdb db, int fd, int flags,
     int prefixLength = strlen(prefix);
     char ** prefixedFileList = NULL;
     struct replacedFile * replacedList = NULL;
+    char * sptr, * dptr;
+    int length;
 
     rc = pkgReadHeader(fd, &h, &isSource);
     if (rc) return rc;
@@ -250,10 +252,25 @@ int rpmInstallPackage(char * prefix, rpmdb db, int fd, int flags,
            }
 
            if (installFile) {
-               /* +1 cuts off leading / */
+               /* 1) we skip over the leading /
+                  2) we have to escape globbing characters :-( */
+
+               length = strlen(fileList[i]);
+               files[archiveFileCount].fileName = alloca((length * 2) + 1);
+               dptr = files[archiveFileCount].fileName;
+               for (sptr = fileList[i] + 1; *sptr; sptr++) {
+                   switch (*sptr) {
+                     case '*': case '[': case ']': case '?': case '\\':
+                       *dptr++ = '\\';
+                       /*fallthrough*/
+                     default:
+                       *dptr++ = *sptr;
+                   }
+               }
+               *dptr++ = *sptr;
 
-               files[archiveFileCount].fileName = fileList[i] + 1;
                files[archiveFileCount].size = fileSizesList[i];
+
                archiveFileCount++;
            }
        }
@@ -982,8 +999,6 @@ static int markReplacedFiles(rpmdb db, struct replacedFile * replList) {
                secOffset = 0;
            } else {
                secHeader = copyHeader(sh);     /* so we can modify it */
-               printf("old size: %d new size: %d\n", sizeofHeader(sh),
-                       sizeofHeader(secHeader));
                freeHeader(sh);
            }