Skip to content

Commit a24c736

Browse files
committed
audit_json_open: Set the close-on-exec flag for the JSON audit fd
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent ba1d5b7 commit a24c736

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

plugins/audit_json/audit_json.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ audit_json_open(unsigned int version, sudo_conv_t conversation,
153153
oldmask = umask(S_IRWXG|S_IRWXO);
154154
fd = open(state.logfile, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
155155
(void)umask(oldmask);
156-
if (fd == -1 || (state.log_fp = fdopen(fd, "w")) == NULL) {
156+
if (fd == -1 || fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||
157+
(state.log_fp = fdopen(fd, "w")) == NULL) {
157158
*errstr = U_("unable to open audit system");
158159
if (fd != -1)
159160
close(fd);

0 commit comments

Comments
 (0)