]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Close socket on error. Bug found by Coverity
authorAlan T. DeKok <aland@freeradius.org>
Thu, 6 Sep 2012 09:18:15 +0000 (11:18 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 6 Sep 2012 09:33:18 +0000 (11:33 +0200)
src/main/command.c

index 5ce3cfe4aaa65705a19a34bdfa5d16ee6811c9a2..7959a6612a25bd5a790811d2dd648de4e7263cc3 100644 (file)
@@ -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;
                }
        }