From dd377fffba04ab3fdd4601befd59a10090c48aeb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 16 Feb 2020 19:11:08 +0100 Subject: [PATCH] analyzer/protocol/dns: fix memory leak If `dns_TSIG_addl` is not set, then the BroString allocated by ExtractOctets() leaks. Therefore, don't ask ExtractOctets() to copy the data to a BroString if we're not going to use it. Yet another memory leak (out of way too many) which would have been prevented by using smart pointers. --- src/analyzer/protocol/dns/DNS.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyzer/protocol/dns/DNS.cc b/src/analyzer/protocol/dns/DNS.cc index db072ffeb3..21b4a0161f 100644 --- a/src/analyzer/protocol/dns/DNS.cc +++ b/src/analyzer/protocol/dns/DNS.cc @@ -769,7 +769,7 @@ int DNS_Interpreter::ParseRR_TSIG(DNS_MsgInfo* msg, unsigned int sign_time_msec = ExtractShort(data, len); unsigned int fudge = ExtractShort(data, len); BroString* request_MAC; - ExtractOctets(data, len, &request_MAC); + ExtractOctets(data, len, dns_TSIG_addl ? &request_MAC : nullptr); unsigned int orig_id = ExtractShort(data, len); unsigned int rr_error = ExtractShort(data, len); ExtractOctets(data, len, 0); // Other Data