]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/iterate: check bad answers missing question
authorMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 28 May 2015 23:46:08 +0000 (01:46 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 28 May 2015 23:46:08 +0000 (01:46 +0200)
lib/layer/iterate.c

index 81cd84674034b85c2cdfceab12933406f9f77198..406aef9024192536b9e2315d9065b48a6c8b8676 100644 (file)
@@ -389,8 +389,10 @@ static int resolve(knot_layer_t *ctx, knot_pkt_t *pkt)
                return ctx->state;
        }
 
-       /* Check for packet processing errors first. */
-       if (pkt->parsed < pkt->size) {
+       /* 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 || pkt->parsed <= KNOT_WIRE_HEADER_SIZE) {
                DEBUG_MSG("<= malformed response\n");
                return resolve_badmsg(pkt, req, query);
        } else if (!is_paired_to_query(pkt, query)) {