]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/io: don't notify worker on udp_recv() errors
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 26 Aug 2020 11:13:51 +0000 (13:13 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Wed, 23 Sep 2020 11:08:11 +0000 (13:08 +0200)
The action doesn't increase any counter or do any error handling.
It would simply SEGFAULT. Even if it didn't worker_submit() would
just return an error code.

daemon/io.c
daemon/worker.c

index 48d2640780742fc888c68fe5c052c4dae6f2ea0f..1c879188d03731f0e8217756474cdf5efbfc6165 100644 (file)
@@ -61,18 +61,9 @@ void udp_recv(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf,
        const struct sockaddr *addr, unsigned flags)
 {
        struct session *s = handle->data;
-       if (session_flags(s)->closing) {
-               return;
-       }
-       if (nread <= 0) {
-               if (nread < 0) { /* Error response, notify resolver */
-                       worker_submit(s, NULL, NULL);
-               } /* nread == 0 is for freeing buffers, we don't need to do this */
+       if (session_flags(s)->closing || nread <= 0 || addr->sa_family == AF_UNSPEC)
                return;
-       }
-       if (addr->sa_family == AF_UNSPEC) {
-               return;
-       }
+
        if (session_flags(s)->outgoing) {
                const struct sockaddr *peer = session_get_peer(s);
                assert(peer->sa_family != AF_UNSPEC);
index 41c8037606bf74fe44e9891370a2fb2a5875f863..45ab8133d76be1dcb9518aa861885bf3e248db0a 100644 (file)
@@ -1583,14 +1583,12 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt
                return kr_error(EINVAL);
        }
 
-       /* Parse packet */
        int ret = parse_packet(query);
 
        const bool is_query = (knot_wire_get_qr(query->wire) == 0);
        const bool is_outgoing = session_flags(session)->outgoing;
        /* Ignore badly formed queries. */
-       if (!query ||
-           (ret != kr_ok() && ret != kr_error(EMSGSIZE)) ||
+       if ((ret != kr_ok() && ret != kr_error(EMSGSIZE)) ||
            (is_query == is_outgoing)) {
                if (query && !is_outgoing) the_worker->stats.dropped += 1;
                return kr_error(EILSEQ);