From: Alan T. DeKok Date: Thu, 6 Sep 2012 09:18:15 +0000 (+0200) Subject: Close socket on error. Bug found by Coverity X-Git-Tag: release_2_2_0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2167cd13f115e198c7c6a8c2d5529e883e41a6e;p=thirdparty%2Ffreeradius-server.git Close socket on error. Bug found by Coverity --- diff --git a/src/main/command.c b/src/main/command.c index 5ce3cfe4aaa..7959a6612a2 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -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; } }