Skip to content

Possible UB on OOM  #7821

Closed
Closed
@paulocsanz

Description

@paulocsanz

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Problem Description

At libraries/Netdump.cpp packetBuffer is dereferenced without checking for nullptr.

packetBuffer is filled at Netdump::tcpDump, but it's with a new (std::nothrow) ... and Netdump::tcpDump is called anyway.

That means if new (std::nothrow) ... returns a null pointer because it's out of memory UB will happen.

I'm prepared to provide a PR to fix it, but I don't know the best way to do this. Should I just check at Netdump::tcpDumpProcess if packetBuffer is filled and return early? Is there a way to warn the user? And I'm not really sure what is the appropriate cleanup code, or if a return; is sufficient.

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