From eea93d2607a766b765448212752a6f043d9e6c66 Mon Sep 17 00:00:00 2001 From: David Baird Date: Fri, 6 May 2022 12:11:47 -0400 Subject: [PATCH] Fix SEGV caused by format string on 32-bit platforms / armv7l, reported in #1587 (#1658) Looks great. Thanks for this! --- node/Bond.cpp | 6 +++--- node/Bond.hpp | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/node/Bond.cpp b/node/Bond.cpp index eb63e38be..e0f56e903 100644 --- a/node/Bond.cpp +++ b/node/Bond.cpp @@ -1724,11 +1724,11 @@ void Bond::dumpPathStatus(int64_t now, int pathIdx) std::string aliveOrDead = _paths[pathIdx].alive ? std::string("alive") : std::string("dead"); std::string eligibleOrNot = _paths[pathIdx].eligible ? std::string("eligible") : std::string("ineligible"); std::string bondedOrNot = _paths[pathIdx].bonded ? std::string("bonded") : std::string("unbonded"); - log("path[%2d] --- %5s (in %7d, out: %7d), %10s, %8s, flows=%-6d lat=%-8.3f pdv=%-7.3f err=%-6.4f loss=%-6.4f alloc=%-3d --- (%s)", + log("path[%2d] --- %5s (in %7lld, out: %7lld), %10s, %8s, flows=%-6d lat=%-8.3f pdv=%-7.3f err=%-6.4f loss=%-6.4f alloc=%-3d --- (%s)", pathIdx, aliveOrDead.c_str(), - _paths[pathIdx].p->age(now), - (now - _paths[pathIdx].p->_lastOut), + static_cast(_paths[pathIdx].p->age(now)), + static_cast(now - _paths[pathIdx].p->_lastOut), eligibleOrNot.c_str(), bondedOrNot.c_str(), _paths[pathIdx].assignedFlowCount, diff --git a/node/Bond.hpp b/node/Bond.hpp index 1c2153bae..d58df4489 100644 --- a/node/Bond.hpp +++ b/node/Bond.hpp @@ -1141,6 +1141,9 @@ class Bond { * */ void log(const char* fmt, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif { #ifdef ZT_TRACE time_t rawtime; @@ -1170,6 +1173,9 @@ class Bond { * */ void debug(const char* fmt, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif { #ifdef ZT_DEBUG time_t rawtime;