Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple fixes in rpmdb (double free, and rpmdbCheckTerminate return code) #92

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/rpmdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ int rpmdbCheckTerminate(int terminate)
sigset_t newMask, oldMask;
static int terminating = 0;

if (terminating) return 0;
if (terminating) return terminating;

(void) sigfillset(&newMask); /* block all signals */
(void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
Expand Down Expand Up @@ -454,6 +454,12 @@ int rpmdbClose(rpmdb db)
if (db == NULL)
goto exit;

prev = &rpmdbRock;
while ((next = *prev) != NULL && next != db)
prev = &next->db_next;
if (!next)
goto exit;

(void) rpmdbUnlink(db);

if (db->nrefs > 0)
Expand All @@ -474,9 +480,6 @@ int rpmdbClose(rpmdb db)
db->db_indexes = _free(db->db_indexes);
db->db_descr = _free(db->db_descr);

prev = &rpmdbRock;
while ((next = *prev) != NULL && next != db)
prev = &next->db_next;
if (next) {
*prev = next->db_next;
next->db_next = NULL;
Expand Down Expand Up @@ -1085,7 +1088,8 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
if (next) {
*prev = next->mi_next;
next->mi_next = NULL;
}
} else
return NULL;

pkgdbOpen(mi->mi_db, 0, &dbi);

Expand Down Expand Up @@ -2085,7 +2089,8 @@ rpmdbIndexIterator rpmdbIndexIteratorFree(rpmdbIndexIterator ii)
if (next) {
*prev = next->ii_next;
next->ii_next = NULL;
}
} else
return NULL;

ii->ii_dbc = dbiCursorFree(ii->ii_dbi, ii->ii_dbc);
ii->ii_dbi = NULL;
Expand Down