Просмотр исходного кода

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 лет назад: 16
Родитель
Сommit
b066610b39
1 измененных файлов с 3 добавлено и 3 удалено
  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)) {