Permalink
Browse files

Close socket on error. Bug found by Coverity

  • Loading branch information...
1 parent 128a7d8 commit b2167cd13f115e198c7c6a8c2d5529e883e41a6e @alandekok alandekok committed Sep 6, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/main/command.c
View
@@ -175,6 +175,7 @@ static int fr_server_domain_socket(const char *path)
if (errno != ENOENT) {
radlog(L_ERR, "Failed to stat %s: %s",
path, strerror(errno));
+ close(sockfd);
return -1;
}
@@ -188,6 +189,7 @@ static int fr_server_domain_socket(const char *path)
#endif
) {
radlog(L_ERR, "Cannot turn %s into socket", path);
+ close(sockfd);
return -1;
}
@@ -196,12 +198,14 @@ static int fr_server_domain_socket(const char *path)
*/
if (buf.st_uid != geteuid()) {
radlog(L_ERR, "We do not own %s", path);
+ close(sockfd);
return -1;
}
if (unlink(path) < 0) {
radlog(L_ERR, "Failed to delete %s: %s",
path, strerror(errno));
+ close(sockfd);
return -1;
}
}

0 comments on commit b2167cd

Please sign in to comment.