From: Adam Heath Date: Tue, 3 Sep 2002 23:36:47 +0000 (+0000) Subject: Fix double free in modstatdb_init, in the case that modstatdb_shutdown was X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe838585164d3a19ac5daa25f49f078264bc7a96;p=dpkg Fix double free in modstatdb_init, in the case that modstatdb_shutdown was called previously. --- diff --git a/ChangeLog b/ChangeLog index 06dcb94f..f2321fd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 3 18:40:08 CDT 2002 Adam Heath + + * 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 * lib/nfmalloc.c: Protect duplicate calls to obstack_free(), diff --git a/debian/changelog b/debian/changelog index 15fe395d..7e9c2068 100644 --- a/debian/changelog +++ b/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 UNRELEASED dpkg (1.10.6) unstable; urgency=low diff --git a/lib/dbmodify.c b/lib/dbmodify.c index 2b69d3fd..d31317b6 100644 --- a/lib/dbmodify.c +++ b/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); }