Project

General

Profile

Actions

Bug #298

closed

tcpdump: leak of dump_if on errors

Added by Sven Eckelmann over 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Low
Target version:
Start date:
10/19/2016
Due date:
% Done:

0%

Estimated time:

Description

Coverity reported following problem

1 new defect(s) introduced to batctl found with Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 153451:  Resource leaks  (RESOURCE_LEAK)
/tcpdump.c: 1304 in tcpdump()

________________________________________________________________________________________________________
*** CID 153451:  Resource leaks  (RESOURCE_LEAK)
/tcpdump.c: 1304 in tcpdump()
1298                            fflush(stdout);
1299                    }
1300     
1301            }
1302     
1303     out:
>>> CID 153451:  Resource leaks  (RESOURCE_LEAK)
>>> Overwriting "dump_if" in "dump_if = ({...})" leaks the storage that "dump_if" points to.
1304            list_for_each_entry_safe(dump_if, dump_if_tmp, &dump_if_list, list) {
1305                    if (dump_if->raw_sock >= 0)
1306                            close(dump_if->raw_sock);
1307     
1308                    list_del(&dump_if->list);
1309                    free(dump_if);

Looks like the problem is not this cleanup loop. Instead it is about a dump_if which is not completely initialized (and thus not part of this list) and then a different error happend which caused a goto to this cleanup routine. The pointer to the allocated dump_if is then overwritten by list_for_each_entry_safe without the memory of it being freed.

Actions #2

Updated by Sven Eckelmann about 7 years ago

  • Status changed from In Progress to Resolved
Actions #3

Updated by Sven Eckelmann about 7 years ago

  • Target version set to 2017.0
Actions #4

Updated by Sven Eckelmann about 7 years ago

  • Assignee set to Sven Eckelmann
Actions #5

Updated by Sven Eckelmann about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF