Skip to content

Commit ce9a715

Browse files
committed
Config parsing error paths can leak memory
When an unknown keyword is encountered, the function returns without freeing nv.values, which can leak memory on repeated parse attempts or reloads.
1 parent 47f6939 commit ce9a715

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

audisp/audispd-pconfig.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ int load_pconfig(plugin_conf_t *config, int dirfd, char *file)
245245
audit_msg(LOG_ERR,
246246
"Unknown keyword \"%s\" in line %d of %s",
247247
nv.name, lineno, file);
248+
nv_free(&nv);
248249
fclose(f);
249250
return 1;
250251
}
251252

252-
/* Check number of options
253+
/* Check number of options
253254
* nv.nvalues is always >= 1, because that's the right part of a 'key = value' conf line
254255
*/
255256
const int noptions = nv.nvalues - 1;
@@ -258,13 +259,15 @@ int load_pconfig(plugin_conf_t *config, int dirfd, char *file)
258259
"Keyword \"%s\" has invalid options "
259260
"in line %d of %s",
260261
nv.name, lineno, file);
262+
nv_free(&nv);
261263
fclose(f);
262264
return 1;
263265
}
264266

265267
/* dispatch to keyword's local parser */
266268
rc = kw->parser(&nv, lineno, config);
267269
if (rc != 0) {
270+
nv_free(&nv);
268271
fclose(f);
269272
return 1; // local parser puts message out
270273
}

0 commit comments

Comments
 (0)