From: W.C.A. Wijngaards Date: Thu, 12 Jun 2025 09:50:11 +0000 (+0200) Subject: - xfr-tsig, check buffer remaining in tsig verify. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19492da15498f0905d02102b73972b3ea52ac4c0;p=thirdparty%2Funbound.git - xfr-tsig, check buffer remaining in tsig verify. --- diff --git a/util/tsig.c b/util/tsig.c index a1253eda1..b0796f402 100644 --- a/util/tsig.c +++ b/util/tsig.c @@ -50,6 +50,43 @@ #include #include +/** + * Skip packet query rr. + * @param pkt: the packet, position before the rr, ends after the rr. + * @return 0 on failure. + */ +static int +skip_pkt_query_rr(struct sldns_buffer* pkt) +{ + /* skip qname */ + if(sldns_buffer_remaining(pkt) < 1) + return 0; + if(!pkt_dname_len(pkt)) + return 0; /* malformed qname */ + if(sldns_buffer_remaining(pkt) < 4) + return 0; + /* skip type and class */ + sldns_buffer_skip(pkt, 2 * sizeof(uint16_t)); + return 1; +} + +/** + * Skip the packet query rrs. The position must be after the header. + * @param pkt: the packet. The end position is after the number of query + * section records. + * @param num: Limit of the number of records we want to parse. + * @return 1 on success, 0 on failure. + */ +static int +skip_pkt_query_rrs(struct sldns_buffer* pkt, int num) +{ + int i; + for(i=0; i fudge ? LDNS_TSIG_ERROR_BADTIME : 0 ) : now - time_signed > fudge ? LDNS_TSIG_ERROR_BADTIME : 0 ; sldns_buffer_set_position(pkt, end_of_message); + /* The TSIG has verified. */ return 0; } + sldns_buffer_set_position(pkt, end_of_message); return LDNS_TSIG_ERROR_BADSIG; }