Skip to content

Commit 9eea4bf

Browse files
committed
Null pointer risks in audisp‑filter config execution
he code calls open(config.config_file, ...) and execve(config.binary, ...) without checking if these pointers are NULL. If configuration is missing or partially parsed, this can segfault. Add validation and fail with a clear error message before these calls.
1 parent ce9a715 commit 9eea4bf

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

audisp/plugins/filter/audisp-filter.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ static int load_rules(struct filter_list* list)
333333
errors = 0;
334334

335335
/* open the file */
336+
if (config.config_file == NULL || config.config_file[0] == '\0') {
337+
syslog(LOG_ERR,
338+
"Config file not set, skipping filter rules");
339+
return 1;
340+
}
336341
if ((fd = open(config.config_file, O_RDONLY)) < 0) {
337342
if (errno != ENOENT) {
338343
syslog(LOG_ERR, "Error opening config file (%s)",
@@ -502,8 +507,17 @@ int main(int argc, const char* argv[])
502507
dup2(pipefd[0], STDIN_FILENO);
503508
close(pipefd[0]);
504509

510+
if (config.binary == NULL || config.binary[0] == '\0' ||
511+
config.binary_args == NULL ||
512+
config.binary_args[0] == NULL) {
513+
syslog(LOG_ERR,
514+
"audisp-filter: missing child command");
515+
exit(1);
516+
}
517+
505518
execve(config.binary, config.binary_args, NULL);
506-
syslog(LOG_ERR, "audisp-filter: execve failed (%s)", strerror(errno));
519+
syslog(LOG_ERR, "audisp-filter: execve failed (%s)",
520+
strerror(errno));
507521
exit(1);
508522
} else {
509523
/* Parent reads input and forwards data after filters have been applied

0 commit comments

Comments
 (0)