mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
Avoid UB and abort on nullptr buffer (#7822)
* Avoid UB and abort on nullptr buffer * Report OOM on return value
This commit is contained in:
parent
34545a160d
commit
07241dd407
@ -84,12 +84,17 @@ 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;
|
||||
|
||||
@ -97,6 +102,7 @@ void Netdump::tcpDump(WiFiServer &tcpDumpServer, const Filter nf)
|
||||
{
|
||||
tcpDumpLoop(tcpDumpServer, nf);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
void Netdump::capture(int netif_idx, const char* data, size_t len, int out, int success)
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user