From 1d57cd6491fe2842d48e01707f1bb202f77d930b Mon Sep 17 00:00:00 2001 From: hreintke Date: Tue, 13 Jul 2021 16:43:38 +0200 Subject: [PATCH 1/2] Fix crash printf long getTime() --- libraries/Netdump/src/Netdump.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Netdump/src/Netdump.cpp b/libraries/Netdump/src/Netdump.cpp index 326f2eaa73..3fcf79298b 100644 --- a/libraries/Netdump/src/Netdump.cpp +++ b/libraries/Netdump/src/Netdump.cpp @@ -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); @@ -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 From 16bb0289798bfb835fd7ff203c764e71c99ec2a9 Mon Sep 17 00:00:00 2001 From: hreintke Date: Tue, 13 Jul 2021 16:44:21 +0200 Subject: [PATCH 2/2] Update several printf to printf_P --- libraries/Netdump/src/NetdumpIP.cpp | 2 +- libraries/Netdump/src/NetdumpPacket.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/Netdump/src/NetdumpIP.cpp b/libraries/Netdump/src/NetdumpIP.cpp index d66459d801..56936c744a 100644 --- a/libraries/Netdump/src/NetdumpIP.cpp +++ b/libraries/Netdump/src/NetdumpIP.cpp @@ -251,7 +251,7 @@ size_t NetdumpIP::printTo(Print& p) uint16_t bit = PP_NTOHS(reinterpret_cast(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 { diff --git a/libraries/Netdump/src/NetdumpPacket.cpp b/libraries/Netdump/src/NetdumpPacket.cpp index 4e2fcbaf6f..bb4e09920c 100644 --- a/libraries/Netdump/src/NetdumpPacket.cpp +++ b/libraries/Netdump/src/NetdumpPacket.cpp @@ -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(); @@ -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