Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 1d500c4

Browse files
author
Ikey Doherty
committed
Fix potential leak, do not allow replacement of discovered pkgs
This fixes an issue in flat clones of repos, whereby an expanded repo may then contain a .spec file further inside the tree beyond its own .spec file, noticed specifically in RPM setups. Signed-off-by: Ikey Doherty <[email protected]>
1 parent 819bba9 commit 1d500c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ static void cve_add_package_internal(struct source_package_t *pkg)
9595
}
9696

9797
if (g_hash_table_contains(self->db, pkg->name)) {
98-
g_hash_table_remove(self->db, pkg->name);
98+
package_free(pkg);
99+
return;
99100
}
100101

101102
if (self->mapping) {
@@ -529,7 +530,6 @@ static bool cve_locate(const char *path, bool recurse)
529530
bool ret = false;
530531
DIR *dir = NULL;
531532
struct dirent *ent = NULL;
532-
char *fullp = NULL;
533533

534534
if (!pkg_plugin || !(pkg_plugin->flags & PLUGIN_TYPE_PACKAGE) || !pkg_plugin->is_package) {
535535
fprintf(stderr, "Abnormal configuration in plugin\n");
@@ -549,13 +549,13 @@ static bool cve_locate(const char *path, bool recurse)
549549
}
550550
while ((ent = readdir(dir))) {
551551
if (!streq(ent->d_name, ".") && !streq(ent->d_name, "..")) {
552+
autofree(char) *fullp = NULL;
552553
if (!asprintf(&fullp, "%s/%s", path, ent->d_name)) {
553554
goto end;
554555
}
555556
if (!(cve_is_dir(fullp) && !recurse)) {
556557
cve_locate(fullp, recurse);
557558
}
558-
free(fullp);
559559
}
560560
}
561561
} else if (S_ISREG(st.st_mode)) {

0 commit comments

Comments
 (0)