Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[server] better checking for read() return value flagged by Coverity

  • Loading branch information...
commit cf6a38ea0dc8e0c66e37da4c3eb926476738deba 1 parent 05d6e1c
@mrash authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 server/fwknopd.c
View
7 server/fwknopd.c
@@ -731,7 +731,7 @@ write_pid_file(fko_srv_options_t *opts)
static pid_t
get_running_pid(const fko_srv_options_t *opts)
{
- int op_fd, is_err;
+ int op_fd, is_err, bytes_read = 0;
char buf[PID_BUFLEN] = {0};
pid_t rpid = 0;
@@ -751,7 +751,8 @@ get_running_pid(const fko_srv_options_t *opts)
return(rpid);
}
- if (read(op_fd, buf, PID_BUFLEN) > 0)
+ bytes_read = read(op_fd, buf, PID_BUFLEN);
+ if (bytes_read > 0)
{
buf[PID_BUFLEN-1] = '\0';
/* max pid value is configurable on Linux
@@ -761,6 +762,8 @@ get_running_pid(const fko_srv_options_t *opts)
if(is_err != FKO_SUCCESS)
rpid = 0;
}
+ else if (bytes_read < 0)
+ perror("Error trying to read() PID file: ");
close(op_fd);

0 comments on commit cf6a38e

Please sign in to comment.
Something went wrong with that request. Please try again.