Skip to content

Commit

Permalink
Netdump printf fix (#8215)
Browse files Browse the repository at this point in the history
* Fix crash printf long getTime()

* Update several printf to printf_P
  • Loading branch information
hreintke authored Jul 17, 2021
1 parent 25a21c3 commit 09c4e33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libraries/Netdump/src/Netdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Netdump::reset()

void Netdump::printDump(Print& out, Packet::PacketDetail ndd, const Filter nf)
{
out.printf("netDump starting\r\n");
out.printf_P(PSTR("netDump starting\r\n"));
setCallback([&out, ndd, this](const Packet & ndp)
{
printDumpProcess(out, ndd, ndp);
Expand Down Expand Up @@ -140,7 +140,7 @@ void Netdump::writePcapHeader(Stream& s) const

void Netdump::printDumpProcess(Print& out, Packet::PacketDetail ndd, const Packet& np) const
{
out.printf_P(PSTR("%8d %s"), np.getTime(), np.toString(ndd).c_str());
out.printf_P(PSTR("%8lld %s"), np.getTime(), np.toString(ndd).c_str());
}

void Netdump::fileDumpProcess(File& outfile, const Packet& np) const
Expand Down
2 changes: 1 addition & 1 deletion libraries/Netdump/src/NetdumpIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ size_t NetdumpIP::printTo(Print& p)
uint16_t bit = PP_NTOHS(reinterpret_cast<const uint16_t*>(rawip)[i]);
if (bit || count0 < 0)
{
n += p.printf("%x", bit);
n += p.printf_P(PSTR("%x"), bit);
if (count0 > 0)
// no more hiding 0
{
Expand Down
10 changes: 5 additions & 5 deletions libraries/Netdump/src/NetdumpPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ void Packet::printDetail(Print& out, const String& indent, const char* data, siz
{
end = size;
}
out.printf("%s", indent.c_str());
out.printf_P(PSTR("%s"), indent.c_str());
if (pd != PacketDetail::CHAR)
{
for (size_t i = start; i < end; i++)
{
out.printf("%02x ", (unsigned char)data[i]);
out.printf_P(PSTR("%02x "), (unsigned char)data[i]);
}
for (size_t i = end; i < start + charCount; i++)
{
out.print(" ");
out.printf_P(PSTR(" "));
}
}
for (size_t i = start; i < end; i++)
{
out.printf("%c", data[i] >= 32 && data[i] < 128 ? data[i] : '.');
out.printf_P(PSTR("%c"), data[i] >= 32 && data[i] < 128 ? data[i] : '.');
}
out.println();

Expand Down Expand Up @@ -253,7 +253,7 @@ void Packet::ICMPtoString(PacketDetail, StreamString& sstr) const
default: sstr.printf_P(PSTR("type(0x%02x)"), getIcmpType()); break;
}
}
sstr.printf("\r\n");
sstr.printf_P(PSTR("\r\n"));
}

void Packet::IGMPtoString(PacketDetail, StreamString& sstr) const
Expand Down

0 comments on commit 09c4e33

Please sign in to comment.