]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: resolvers: fix memory leak on AAAA additional records
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Apr 2026 11:06:41 +0000 (13:06 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 9 Apr 2026 14:31:05 +0000 (16:31 +0200)
Commit c84c15d3938a ("BUG/MINOR: resolvers: Apply dns-accept-family
setting on additional records") converted a switch statement to an
if/else chain but left the break; in the AAAA branch. In the new
form, break exits the surrounding for loop instead of a switch case.

For every AAAA additional record in an SRV response:
  - answer_record allocated at line 1460 is never freed and never
    inserted into answer_tree -> ~580 bytes leaked per response
  - all subsequent additional records in the response are silently
    discarded

A DNS server controlling SRV responses for haproxy service discovery
can leak memory at MB/min rates given default resolution intervals.
Also breaks IPv6 SRV target resolution outright since the AAAA record
is leaked rather than attached to its SRV entry.

src/resolvers.c

index 1b17b11e0a0df43fdc228027269bd2fb87d188bb..30b0cf796a76823e948231c8d7a0abec7663a617 100644 (file)
@@ -1527,7 +1527,6 @@ static int resolv_validate_dns_response(unsigned char *resp, unsigned char *bufe
                                goto invalid_resp;
                        answer_record->data.in6.sin6_family = AF_INET6;
                        memcpy(&answer_record->data.in6.sin6_addr, reader, answer_record->data_len);
-                       break;
                }
                else {
                        pool_free(resolv_answer_item_pool, answer_record);