Skip to content

Commit

Permalink
Fix leak of dpkg cache when dpkginfo_init is called multiple times
Browse files Browse the repository at this point in the history
In the dpkginfo probe, the dpkg cache was allocated in dpkginfo_init.
However, dpkginfo_init can be called multiple times, leading the
cgCache pointer to be overridden and leaking the dpkg cache.
  • Loading branch information
0intro committed Feb 22, 2023
1 parent 7111011 commit 50206b2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/OVAL/probes/unix/linux/dpkginfo-helper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ void dpkginfo_free_reply(struct dpkginfo_reply_t *reply)

int dpkginfo_init()
{
if (cgCache != NULL) {
return 0;
}

cgCache = new pkgCacheFile;
if (_init_done == 0)
if (opencache() != 1) {
Expand Down

0 comments on commit 50206b2

Please sign in to comment.