Skip to content

Commit

Permalink
analyzer/protocol/dns: fix memory leak
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaxKellermann committed Feb 16, 2020
1 parent 2a7f2e0 commit dd377ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/analyzer/protocol/dns/DNS.cc
Expand Up @@ -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
Expand Down

0 comments on commit dd377ff

Please sign in to comment.