Explorar el Código

dpkg-deb: Fix double free in --info

Change the code to not increase cdlist, and instead index it, so that
we can free it at the end.

Regression introduced in commit c264dd83d33250927fe165de5336145afdf99610.
Guillem Jover hace 16 años
padre
commit
b066610b39
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      dpkg-deb/info.c

+ 3 - 3
dpkg-deb/info.c

@@ -131,7 +131,7 @@ static void info_list(const char *debar, const char *directory) {
   char interpreter[INTERPRETER_MAX+1], *p;
   int il, lines;
   struct dirent **cdlist, *cdep;
-  int cdn;
+  int cdn, n;
   FILE *cc;
   struct stat stab;
   int c;
@@ -139,8 +139,8 @@ static void info_list(const char *debar, const char *directory) {
   cdn= scandir(".", &cdlist, &ilist_select, alphasort);
   if (cdn == -1) ohshite(_("cannot scan directory `%.255s'"),directory);
 
-  while (cdn-- >0) {
-    cdep= *cdlist++;
+  for (n = 0; n < cdn; n++) {
+    cdep = cdlist[n];
     if (stat(cdep->d_name,&stab))
       ohshite(_("cannot stat `%.255s' (in `%.255s')"),cdep->d_name,directory);
     if (S_ISREG(stab.st_mode)) {