Skip to content

Commit 61c5a99

Browse files
committed
journal_fdopen: free closure->journal_path on fdopen() error
If fdopen() fails, free and zero out closure->journal_path to clean up before returning. Other parts of logsrvd inspect closure->journal_path and use it to determine if journaling is being performed. Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent ddb9cfe commit 61c5a99

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

logsrvd/logsrvd_journal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ journal_fdopen(int fd, const char *journal_path,
7878
if ((closure->journal = fdopen(fd, "r+")) == NULL) {
7979
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
8080
"unable to fdopen journal file %s", journal_path);
81+
free(closure->journal_path);
82+
closure->journal_path = NULL;
8183
debug_return_bool(false);
8284
}
8385

0 commit comments

Comments
 (0)