From: Tomas Krizek Date: Thu, 1 Oct 2020 12:09:47 +0000 (+0200) Subject: daemon/http: make sure uv_handle is always initialized X-Git-Tag: v5.2.0~15^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=136c167eeb4f428e82df3ca6be5957cc6f055d89;p=thirdparty%2Fknot-resolver.git daemon/http: make sure uv_handle is always initialized It is later closed in endpoint_close(), which would fail with assert if not initialized (e.g. when compiled without nghttp2 support and attempting to use doh2 kind). --- diff --git a/daemon/io.c b/daemon/io.c index f64ead4f8..ce4c46df6 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -497,11 +497,18 @@ static void https_accept(uv_stream_t *master, int status) int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bool has_tls, bool has_http) { uv_connection_cb connection; + + if (!handle) { + return kr_error(EINVAL); + } + int ret = uv_tcp_init(loop, handle); + if (ret) return ret; + if (has_tls && has_http) { #ifdef ENABLE_DOH2 connection = https_accept; #else - kr_log_error("[ io ] kresd was compiled without libnghttp2 support"); + kr_log_error("[ io ] kresd was compiled without libnghttp2 support\n"); return kr_error(ENOPROTOOPT); #endif } else if (has_tls) { @@ -512,12 +519,6 @@ int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bo connection = tcp_accept; } - if (!handle) { - return kr_error(EINVAL); - } - int ret = uv_tcp_init(loop, handle); - if (ret) return ret; - ret = uv_tcp_open(handle, (uv_os_sock_t) fd); if (ret) return ret;