Parcourir la source

Do not use strdup for execvp arguments

Closes: #379027
Guillem Jover il y a 18 ans
Parent
commit
0ceb5d63d6
3 fichiers modifiés avec 17 ajouts et 8 suppressions
  1. 5 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 11 8
      src/archives.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-01-01  Guillem Jover  <guillem@debian.org>
+
+	* src/archives.c (archivefiles): Remove pointless strdup for execvp
+	arguments.
+
 2008-01-01  Ian Zimmerman  <itz@buug.org>
 2008-01-01  Ian Zimmerman  <itz@buug.org>
 
 
 	* scripts/install-info.pl: Ignore wrapped lines when matching
 	* scripts/install-info.pl: Ignore wrapped lines when matching

+ 1 - 0
debian/changelog

@@ -21,6 +21,7 @@ dpkg (1.14.15) UNRELEASED; urgency=low
   * Ignore wrapped lines in install-info when matching section titles.
   * Ignore wrapped lines in install-info when matching section titles.
     Closes: #214684
     Closes: #214684
     Thanks to Andreas Metzler and Ian Zimmerman.
     Thanks to Andreas Metzler and Ian Zimmerman.
+  * Do not use strdup for execvp arguments. Closes: #379027
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * Norwegian Bokmål (Hans Fredrik Nordhaug). Closes: #457918
   * Norwegian Bokmål (Hans Fredrik Nordhaug). Closes: #457918

+ 11 - 8
src/archives.c

@@ -1097,7 +1097,7 @@ void archivefiles(const char *const *argv) {
       m_dup2(pi[1],1); close(pi[0]); close(pi[1]);
       m_dup2(pi[1],1); close(pi[0]); close(pi[1]);
       for (i=0, ap=argv; *ap; ap++, i++);
       for (i=0, ap=argv; *ap; ap++, i++);
       narglist= m_malloc(sizeof(char*)*(i+15));
       narglist= m_malloc(sizeof(char*)*(i+15));
-      narglist[0]= strdup(FIND);
+      narglist[0] = FIND;
       for (i=1, ap=argv; *ap; ap++, i++) {
       for (i=1, ap=argv; *ap; ap++, i++) {
         if (strchr(FIND_EXPRSTARTCHARS,(*ap)[0])) {
         if (strchr(FIND_EXPRSTARTCHARS,(*ap)[0])) {
           char *a;
           char *a;
@@ -1106,15 +1106,18 @@ void archivefiles(const char *const *argv) {
           strcat(a,*ap);
           strcat(a,*ap);
           narglist[i]= a;
           narglist[i]= a;
         } else {
         } else {
-          narglist[i]= strdup(*ap);
+          narglist[i] = (char *)*ap;
         }
         }
       }
       }
-      narglist[i++]= strdup("-follow"); /*  When editing these, make sure that     */
-      narglist[i++]= strdup("-name");   /*  arglist is mallocd big enough, above.  */
-      narglist[i++]= strdup(ARCHIVE_FILENAME_PATTERN);
-      narglist[i++]= strdup("-type");
-      narglist[i++]= strdup("f");
-      narglist[i++]= strdup("-print0");
+      /* When editing these, make sure that arglist is malloced big enough,
+       * above.
+       */
+      narglist[i++] = "-follow";
+      narglist[i++] = "-name";
+      narglist[i++] = ARCHIVE_FILENAME_PATTERN;
+      narglist[i++] = "-type";
+      narglist[i++] = "f";
+      narglist[i++] = "-print0";
       narglist[i++]= 0;
       narglist[i++]= 0;
       execvp(FIND, narglist);
       execvp(FIND, narglist);
       ohshite(_("failed to exec find for --recursive"));
       ohshite(_("failed to exec find for --recursive"));