charon: Explicitly check return value of fileno()
This is mainly for Coverity because fchown() can't take a negative value, which the -1 check implies is possible.
This commit is contained in:
@@ -211,7 +211,12 @@ static bool check_pidfile()
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = fileno(pidfile);
|
fd = fileno(pidfile);
|
||||||
if (fd == -1 || fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
DBG1(DBG_DMN, "unable to determine fd for '%s'", pidfile_name);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "setting FD_CLOEXEC for '%s' failed: %s",
|
DBG1(DBG_LIB, "setting FD_CLOEXEC for '%s' failed: %s",
|
||||||
pidfile_name, strerror(errno));
|
pidfile_name, strerror(errno));
|
||||||
|
|||||||
+6
-1
@@ -221,7 +221,12 @@ static bool check_pidfile()
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = fileno(pidfile);
|
fd = fileno(pidfile);
|
||||||
if (fd == -1 || fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
DBG1(DBG_DMN, "unable to determine fd for '"PID_FILE"'");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "setting FD_CLOEXEC for '"PID_FILE"' failed: %s",
|
DBG1(DBG_LIB, "setting FD_CLOEXEC for '"PID_FILE"' failed: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|||||||
Reference in New Issue
Block a user