]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
address coverity issues
authorAlan T. DeKok <aland@freeradius.org>
Tue, 23 Jan 2024 21:32:38 +0000 (16:32 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 23 Jan 2024 21:32:38 +0000 (16:32 -0500)
src/lib/bio/fd.c
src/lib/bio/fd_open.c

index 563ae91fac956d4d8df75b0e167a9388ea6c5049..707daae4f8ef6304ff7efcf4e279f5a884592703 100644 (file)
@@ -296,6 +296,10 @@ static ssize_t fd_fd_recvfromto_common(fr_bio_fd_t *my, void *packet_ctx, void *
        struct sockaddr_storage from;
        fr_bio_fd_packet_ctx_t *addr = fr_bio_fd_packet_ctx(my, packet_ctx);
 
+#ifdef STATIC_ANALYZER
+       from.af = AF_UNSPEC;
+#endif
+
        my->info.read_blocked = false;
 
        memset(&my->cbuf, 0, sizeof(my->cbuf));
index 1439019c6567e2dce633b2d11eda1bb2219520b1..246a9fa4455e3e384dc3805df9ae5cb0f6434046 100644 (file)
@@ -282,7 +282,7 @@ static int fr_bio_fd_socket_unix_mkdir(int *dirfd, char const **filename, fr_bio
        mode_t perm;
        int parent_fd, fd;
        char const *path = cfg->path;
-       char *dir, *p;
+       char *p, *dir = NULL;
        char *slashes[2];
 
        perm = S_IREAD | S_IWRITE | S_IEXEC;
@@ -299,18 +299,20 @@ static int fr_bio_fd_socket_unix_mkdir(int *dirfd, char const **filename, fr_bio
 
                if (fstat(*dirfd, &buf) < 0) {
                        fr_strerror_printf("Failed reading parent directory for file %s: %s", path, fr_syserror(errno));
+               fail:
+                       talloc_free(dir);
                        close(*dirfd);
                        return -1;
                }
 
                if (buf.st_uid != cfg->uid) {
                        fr_strerror_printf("Failed reading parent directory for file %s: Incorrect UID", path);
-                       return -1;
+                       goto fail;
                }
 
                if (buf.st_gid != cfg->gid) {
                        fr_strerror_printf("Failed reading parent directory for file %s: Incorrect GID", path);
-                       return -1;
+                       goto fail;
                }
 
                /*
@@ -320,15 +322,14 @@ static int fr_bio_fd_socket_unix_mkdir(int *dirfd, char const **filename, fr_bio
                 */
                if (fchmod(*dirfd, perm) < 0) {
                        fr_strerror_printf("Failed setting parent directory permissions for file %s: %s", path, fr_syserror(errno));
-                       close(*dirfd);
-                       return -1;
+                       goto fail;
                }
 
                return 0;
        }
 
        dir = talloc_strdup(NULL, path);
-       if (!dir) return -1;
+       if (!dir) goto fail;
 
        /*
         *      Find the last two directory separators.
@@ -348,9 +349,7 @@ static int fr_bio_fd_socket_unix_mkdir(int *dirfd, char const **filename, fr_bio
         */
        if (!slashes[0]) {
                fr_strerror_printf("Failed parsing filename %s: it is not absolute", path);
-       fail:
-               talloc_free(dir);
-               return -1;
+               goto fail;
        }
 
        /*