]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
libknot: avoid calling close(-1) (Coverity)
authorDaniel Salzman <daniel.salzman@nic.cz>
Sun, 29 Jun 2025 18:55:21 +0000 (20:55 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 30 Jun 2025 04:55:48 +0000 (06:55 +0200)
src/libknot/quic/tls_common.c

index 65cab40cc7ae77e2e6536b189d8c7fca82ed1779..4277414fdfe4ad69f2122c98190435f9c5631e62 100644 (file)
@@ -284,7 +284,9 @@ static void hash_file(SIPHASH_CTX *ctx, const char *file_name)
        if (fd == -1 ||
            fstat(fd, &file_stat) == -1 ||
            (data = mmap(0, file_stat.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
-               close(fd);
+               if (fd > -1) {
+                       close(fd);
+               }
                return;
        }