Przeglądaj źródła

Fix double free in modstatdb_init, in the case that modstatdb_shutdown was
called previously.

Adam Heath 24 lat temu
rodzic
commit
fe83858516
3 zmienionych plików z 21 dodań i 9 usunięć
  1. 5 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 13 9
      lib/dbmodify.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Tue Sep  3 18:40:08 CDT 2002 Adam Heath <doogie@debian.org>
+
+  * lib/dbmodify.c: Fix double free in modstatdb_init, in the case that
+    modstatdb_shutdown was called previously.
+
 Tue Sep  3 18:37:45 CDT 2002 Adam Heath <doogie@debian.org>
 
   * lib/nfmalloc.c: Protect duplicate calls to obstack_free(),

+ 3 - 0
debian/changelog

@@ -1,5 +1,8 @@
 dpkg (1.10.7) unstable; urgency=low
 
+  * Fix double free in modstatdb_init, in the case that modstatdb_shutdown
+    was called previously.  Closes: #159515.
+
  -- Adam Heath <doogie@debian.org>  UNRELEASED
 
 dpkg (1.10.6) unstable; urgency=low

+ 13 - 9
lib/dbmodify.c

@@ -119,13 +119,15 @@ static void createimptmp(void) {
   onerr_abort--;
 }
 
+const struct fni { const char *suffix; char **store; } fnis[]= {
+  {   STATUSFILE,                 &statusfile         },
+  {   AVAILFILE,                  &availablefile      },
+  {   UPDATESDIR IMPORTANTTMP,    &importanttmpfile   },
+  {   NULL, NULL                                      }
+};
+
 enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritereq) {
-  static const struct fni { const char *suffix; char **store; } fnis[]= {
-    {   STATUSFILE,                 &statusfile         },
-    {   AVAILFILE,                  &availablefile      },
-    {   UPDATESDIR IMPORTANTTMP,    &importanttmpfile   },
-    {   NULL, NULL                                      }
-  }, *fnip;
+  const struct fni *fnip;
   
   admindir= adir;
 
@@ -203,6 +205,7 @@ static void checkpoint(void) {
 }
 
 void modstatdb_shutdown(void) {
+  const struct fni *fnip;
   switch (cstatus) {
   case msdbrw_write:
     checkpoint();
@@ -218,9 +221,10 @@ void modstatdb_shutdown(void) {
     break;
   }
 
-  free(statusfile);
-  free(availablefile);
-  free(importanttmpfile);
+  for (fnip=fnis; fnip->suffix; fnip++) {
+    free(*fnip->store);
+    *fnip->store= NULL;
+  }
   free(updatefnbuf);
 }