Skip to content

pcap_lookupdev may dereference NULL due to incorrect return condition #172

@MarkLee131

Description

@MarkLee131

In function pcap_lookupdev, the return condition is incorrect and can lead to a NULL pointer dereference.

Specifically, the code snippet is:

if (pcap_findalldevs( &devs, errbuf ) == -1 || devs) return NULL;

With the current logic, the function proceeds only when pcap_findalldevs returns success and devs == NULL, and then unconditionally dereferences devs.

Since function pcap_lookupdev is exported (as shownwpcap.spec) and externally callable,

@ cdecl pcap_lookupdev(ptr)

this results in a reachable crash if pcap_findalldevs returns 0 while leaving devs unset.

The condition likely should be || !devs instead of || devs.

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