Przeglądaj źródła

dpkg-deb: Fix resource leak in --info

“dpkg-deb -I foo.deb” leaks the file handle for the package’s
control file. Check for read errors and close the file before
it falls out of scope.

Found by cppcheck.

Reported-by: Raphael Geissert <atomo64@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Jonathan Nieder 16 lat temu
rodzic
commit
5e03628e92
2 zmienionych plików z 8 dodań i 0 usunięć
  1. 4 0
      debian/changelog
  2. 4 0
      dpkg-deb/info.c

+ 4 - 0
debian/changelog

@@ -87,6 +87,10 @@ dpkg (1.15.6) UNRELEASED; urgency=low
     present in the symbol file (Closes: #541464). Please note, however, that
     there is no way to detect symbol changes in the pattern match sets.
 
+  [ Jonathan Nieder ]
+  * Fix a file handle leak in “dpkg-deb --info”. Thanks to Raphael Geissert
+    for the report and patch.
+
   [ Updated dpkg translations ]
   * French (Christian PERRIER).
   * German (Sven Joachim).

+ 4 - 0
dpkg-deb/info.c

@@ -186,6 +186,10 @@ static void info_list(const char *debar, const char *directory) {
     }
     if (!lines)
       putc('\n', stdout);
+
+    if (ferror(cc))
+      ohshite(_("failed to read `%.255s' (in `%.255s')"), "control", directory);
+    fclose(cc);
   }
 
   m_output(stdout, _("<standard output>"));