Skip to contentSkip to conversation

restorecond: close the PID file if writing to it failed

PATCH In review Nicolas Iooss 2 participants 2 messages Jul 1, 2018 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 restorecond: close the PID file if writing to it failed

write_pid_file() leaks a file descriptor to /var/run/restorecond.pid if it fails to write the PID to it. Close the file before returning.

---
 restorecond/restorecond.c | 1 +
 1 file changed, 1 insertion(+)
restorecond/restorecond.c +1 -0
index 6fbbd35dc1b3..e1d26cb9190d 100644
@@ -105,6 +105,7 @@ static int write_pid_file(void)
 	}
 	if (write(pidfd, val, (unsigned int)len) != len) {
 		syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno));
+		close(pidfd);
 		return 1;
 	}
 	close(pidfd);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 23 lines · Nicolas Iooss

write_pid_file() leaks a file descriptor to /var/run/restorecond.pid if it fails to write the PID to it. Close the file before returning.

---
 restorecond/restorecond.c | 1 +
 1 file changed, 1 insertion(+)
restorecond/restorecond.c +1 -1
index 6fbbd35dc1b3..e1d26cb9190d 100644
@@ -105,6 +105,7 @@ static int write_pid_file(void)
        }
        if (write(pidfd, val, (unsigned int)len) != len) {
                syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno));
+               close(pidfd);
                return 1;
        }
        close(pidfd);
--

2.17.1

Quoted 5 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

ack