Skip to content

Resource leak caused by the mismatch of pcap_create and pcap_close #1233

@PromptFuzz

Description

@PromptFuzz

Hi,
I have found that if call pcap_close() intermediatly after the pcap_create() could cause a eventfd leak.

The example code is:

    if (pcap_findalldevs(&devs, errbuf) == -1) {
     ...
    }
    // Open first device for capturing
    handle = pcap_create(devs->name, errbuf);
    //pcap_activate(handle);
    pcap_close(handle);   

My environment :
OS: CentOS 5.4
Run with non-privileged user account

Rerpoduce:
In
poc.zip.

fd_leak

I have noticed that pcap_create has announced:

The returned handle must be activated with pcap_activate(3PCAP) before packets can be captured with it;

Actually, the leak was disappeared if i called pcap_activate(handle); after the pcap_create().
But, for general use, the pcap_create and pcap_close should be match, regardless whether we use or not use the returned handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions