Browse Source

Don't spew out garbage from dpkg-deb, if the second argument
to -I is a absolute filename. Based on a patch by Ian Eure.
Closes: #35573

Frank Lichtenheld 20 years ago
parent
commit
56fc1d3b96
3 changed files with 24 additions and 3 deletions
  1. 5 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 16 3
      dpkg-deb/info.c

+ 5 - 0
ChangeLog

@@ -1,5 +1,10 @@
 2006-05-12  Frank Lichtenheld  <djpig@debian.org>
 2006-05-12  Frank Lichtenheld  <djpig@debian.org>
 
 
+	* dpkg-deb/info.c (info_spew): Prepend the name of the
+	directory we're in to the control component name. This
+	way we don't spew out garbage if we get an absolute
+	path as component name.
+
 	* scripts/dpkg-scanpackages.pl: Print usage
 	* scripts/dpkg-scanpackages.pl: Print usage
 	information on stderr instead of stdout in
 	information on stderr instead of stdout in
 	case of error. Only print it on stdout if
 	case of error. Only print it on stdout if

+ 3 - 0
debian/changelog

@@ -20,6 +20,9 @@ dpkg (1.13.20~) UNRELEASED; urgency=low
   * Improve the description of --show-format in dpkg-deb
   * Improve the description of --show-format in dpkg-deb
     man page and add a pointer to the complete description
     man page and add a pointer to the complete description
     of the option in dpkg-query.
     of the option in dpkg-query.
+  * Don't spew out garbage from dpkg-deb, if the second argument
+    to -I is a absolute filename. Based on a patch by Ian Eure.
+    Closes: #35573
 
 
   [ Nicolas François ]
   [ Nicolas François ]
   * fix typos in the Russian man pages. Thanks to Stepan Golosunov.
   * fix typos in the Russian man pages. Thanks to Stepan Golosunov.

+ 16 - 3
dpkg-deb/info.c

@@ -86,22 +86,35 @@ static int ilist_select(const struct dirent *de) {
 static void info_spew(const char *debar, const char *directory,
 static void info_spew(const char *debar, const char *directory,
                       const char *const *argv) {
                       const char *const *argv) {
   const char *component;
   const char *component;
+  size_t pathlen;
+  char *controlfile = NULL;
   FILE *co;
   FILE *co;
   int re= 0;
   int re= 0;
 
 
   while ((component= *argv++) != 0) {
   while ((component= *argv++) != 0) {
-    co= fopen(component,"r");
+    pathlen = strlen(directory) + strlen(component) + 2;
+    controlfile = (void *) realloc((void *) controlfile, pathlen);
+    if (!controlfile)
+      ohshite(_("realloc failed (%ld bytes)"), pathlen);
+    memset(controlfile, 0, sizeof(controlfile));
+
+    strcat(controlfile, directory);
+    strcat(controlfile, "/");
+    strcat(controlfile, component);
+    co= fopen(controlfile,"r");
+
     if (co) {
     if (co) {
       stream_fd_copy(co, 1, -1, _("info_spew"));
       stream_fd_copy(co, 1, -1, _("info_spew"));
     } else if (errno == ENOENT) {
     } else if (errno == ENOENT) {
       if (fprintf(stderr, _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"),
       if (fprintf(stderr, _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"),
-                  debar, component) == EOF) werr("stderr");
+		  debar, component) == EOF) werr("stderr");
       re++;
       re++;
     } else {
     } else {
       ohshite(_("open component `%.255s' (in %.255s) failed in an unexpected way"),
       ohshite(_("open component `%.255s' (in %.255s) failed in an unexpected way"),
-              component, directory);
+	      component, directory);
     }
     }
   }
   }
+  free(controlfile);
   if (re==1)
   if (re==1)
     ohshit(_("One requested control component is missing"));
     ohshit(_("One requested control component is missing"));
   else if (re>1)
   else if (re>1)