the-tcpdump-group / tcpdump

the TCPdump network dissector
https://www.tcpdump.org/
Other
2.73k stars 852 forks source link

Fix Memory Leak and Improve Error Handling in `find_interface_by_number` Function #1211

Closed RoseSecurity closed 3 months ago

RoseSecurity commented 3 months ago

What and Why

This pull request addresses a potential memory leak and improves error handling in the find_interface_by_number function within tcpdump.c. The issue was identified when the pcap_findalldevs or pcap_findalldevs_ex function call failed, leading to an early exit without freeing the allocated memory for the device list (devlist). This pull request ensures proper memory management by freeing resources before exiting the function on error.

guyharris commented 3 months ago

Already fixed in the main branch in 11e8f0a2ecaf6e391ab412b1b23ece0ddac2dd0c and in the 4.99 branch in 830c52e09f41ac82a25a201bf1fd042395f6c8b4.