Skip to content

Possible UB on OOM #7821

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
6 tasks done
paulocsanz opened this issue Jan 12, 2021 · 0 comments · Fixed by #7822
Closed
6 tasks done

Possible UB on OOM #7821

paulocsanz opened this issue Jan 12, 2021 · 0 comments · Fixed by #7822

Comments

@paulocsanz
Copy link
Contributor

paulocsanz commented Jan 12, 2021

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.

No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant