Skip to content

Avoid UB and abort on nullptr buffer #7822

New issue

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

By clicking “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? Sign in to your account

Merged
merged 4 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion libraries/Netdump/src/Netdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,25 @@ void Netdump::fileDump(File& outfile, const Filter nf)
fileDumpProcess(outfile, ndp);
}, nf);
}
void Netdump::tcpDump(WiFiServer &tcpDumpServer, const Filter nf)
bool Netdump::tcpDump(WiFiServer &tcpDumpServer, const Filter nf)
{

if (!packetBuffer)
{
packetBuffer = new (std::nothrow) char[tcpBufferSize];

if (!packetBuffer)
{
return false;
}
}
bufferIndex = 0;

schedule_function([&tcpDumpServer, this, nf]()
{
tcpDumpLoop(tcpDumpServer, nf);
});
return true;
}

void Netdump::capture(int netif_idx, const char* data, size_t len, int out, int success)
Expand Down
2 changes: 1 addition & 1 deletion libraries/Netdump/src/Netdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Netdump

void printDump(Print& out, Packet::PacketDetail ndd, const Filter nf = nullptr);
void fileDump(File& outfile, const Filter nf = nullptr);
void tcpDump(WiFiServer &tcpDumpServer, const Filter nf = nullptr);
bool tcpDump(WiFiServer &tcpDumpServer, const Filter nf = nullptr);


private:
Expand Down