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.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2018-05-26 23:53:30 +02:00
parent f032946cf9
commit 2b0fbebd50
No known key found for this signature in database
GPG key ID: C191415F340DAAA0

View file

@ -105,6 +105,7 @@ static int write_pid_file(void)
} }
if (write(pidfd, val, (unsigned int)len) != len) { if (write(pidfd, val, (unsigned int)len) != len) {
syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno)); syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno));
close(pidfd);
return 1; return 1;
} }
close(pidfd); close(pidfd);