From: Alan T. DeKok Date: Tue, 5 Oct 2021 20:48:54 +0000 (-0400) Subject: refresh dns_labels struct, instead of reallocating it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b375ff5ef66462368deb943a23677afad4adfaaa;p=thirdparty%2Ffreeradius-server.git refresh dns_labels struct, instead of reallocating it which cuts down on the leaks while fuzzing, but doesn't eliminate them. --- diff --git a/src/protocols/dns/decode.c b/src/protocols/dns/decode.c index b6e1340eaf..6b3b6c923b 100644 --- a/src/protocols/dns/decode.c +++ b/src/protocols/dns/decode.c @@ -580,8 +580,21 @@ static ssize_t fr_dns_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *list, uint8_ packet_ctx->packet = data; packet_ctx->packet_len = data_len; - packet_ctx->lb = fr_dns_labels_init(packet_ctx, data, 256); - fr_assert(packet_ctx->lb != NULL); + if (packet_ctx->lb) { + fr_dns_labels_t *lb = packet_ctx->lb; + + lb->start = data; + + /* + * Always skip the DNS packet header. + */ + lb->blocks[0].start = 12; + lb->blocks[0].end = 12; + lb->num = 1; + } else { + packet_ctx->lb = fr_dns_labels_init(packet_ctx, data, 256); + fr_assert(packet_ctx->lb != NULL); + } return fr_dns_decode(ctx, data, data_len, &cursor, packet_ctx); }