]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/io: catch fdopen fail, close fd and default back to stdout docs-lint-tidy-fi-8vb3i4/deployments/7485
authorFrantisek Tobias <frantisek.tobias@nic.cz>
Mon, 25 Aug 2025 14:30:52 +0000 (16:30 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 27 Aug 2025 06:57:15 +0000 (08:57 +0200)
daemon/io.c
daemon/network.c

index 79a586b24583dc8204d2c332a5ab6b9703766b97..3f609c6e533301b340d0caefa77d5f336bf6862c 100644 (file)
@@ -565,11 +565,12 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu
                if (dup_fd >= 0) {
                        out = fdopen(dup_fd, "w");
                }
-       }
 
-       /* Avoid Null pointer */
-       if (!out) {
-               return;
+               if (!out) {
+                       close(dup_fd);
+                       /* fallback to standard output */
+                       out = stdout;
+               }
        }
 
        /** The current single command and the remaining command(s). */
index d4088bbaa5cdb874e31a4ddc75e221dc2a8f8b23..0a6ebf317df6b6d4fe7c4a6a85dca91f57f2574e 100644 (file)
@@ -919,8 +919,9 @@ static int clear_bpf_cb(trie_val_t *val, void *ctx)
                        uv_fileno(endpoint->handle, &sockfd);
                kr_require(sockfd != -1);
 
+               /* appease linter, kernel ignores optval for SO_DETACH_BPF */
                int no = 0;
-               if (setsockopt(sockfd, SOL_SOCKET, SO_DETACH_BPF, &no, sizeof(no)) != 0) {
+               if (setsockopt(sockfd, SOL_SOCKET, SO_DETACH_BPF, &no, 0) != 0) {
                        kr_log_error(NETWORK, "failed to clear SO_DETACH_BPF socket option\n");
                }
                /* Proceed even if setsockopt() failed,