From: Alan T. DeKok Date: Tue, 23 Jan 2024 21:32:38 +0000 (-0500) Subject: address coverity issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=227b0de3abb2d2971bdd5399df503ab07658b2b5;p=thirdparty%2Ffreeradius-server.git address coverity issues --- diff --git a/src/lib/bio/fd.c b/src/lib/bio/fd.c index 563ae91fac9..707daae4f8e 100644 --- a/src/lib/bio/fd.c +++ b/src/lib/bio/fd.c @@ -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)); diff --git a/src/lib/bio/fd_open.c b/src/lib/bio/fd_open.c index 1439019c656..246a9fa4455 100644 --- a/src/lib/bio/fd_open.c +++ b/src/lib/bio/fd_open.c @@ -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; } /*