]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
squash! iterate.c: fail on execissive data in a packet remove_compile_time_strict_mode 1132/head 76200
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 8 Feb 2021 08:30:25 +0000 (09:30 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 8 Feb 2021 08:35:34 +0000 (09:35 +0100)
but lower priority of this, below RCODE errors.

lib/layer/iterate.c

index 0a09a9006ceff3174ba65ad2f91a43172aef6a33..c79126e1fda6e9b10589ea8592963bdea6e8eb7b 100644 (file)
@@ -999,10 +999,7 @@ static int resolve(kr_layer_t *ctx, knot_pkt_t *pkt)
        /* Check for packet processing errors first.
         * Note - we *MUST* check if it has at least a QUESTION,
         * otherwise it would crash on accessing QNAME. */
-       if (pkt->parsed < pkt->size) {
-               VERBOSE_MSG("<= pkt contains excessive data\n");
-               return KR_STATE_FAIL;
-       } else if (pkt->parsed <= KNOT_WIRE_HEADER_SIZE) {
+       if (pkt->parsed <= KNOT_WIRE_HEADER_SIZE) {
                if (pkt->parsed == KNOT_WIRE_HEADER_SIZE && knot_wire_get_rcode(pkt->wire) == KNOT_RCODE_FORMERR) {
                        /* This is a special case where we get valid header with FORMERR and nothing else.
                         * This happens on some authoritatives which don't support EDNS and don't
@@ -1102,6 +1099,12 @@ static int resolve(kr_layer_t *ctx, knot_pkt_t *pkt)
                return ret;
        }
 
+       if (pkt->parsed < pkt->size) {
+               VERBOSE_MSG("<= ignoring packet due to containing excessive data (%zu bytes)\n",
+                               pkt->size - pkt->parsed);
+               return KR_STATE_FAIL;
+       }
+
        int state;
        /* Forwarding/stub mode is special. */
        if (query->flags.STUB) {