log: show placeholders for missing peer fields
What changed, and why it matters
This is a minor logging-only change. When Bitcoin Core logs debug messages about a peer, it now prints '<unknown-addr>' or '<no user agent>' instead of leaving the field blank when that information is missing. It does not change how the program behaves, only how two debug log lines look.
No security action needed. Treat as a normal code-quality/logging improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies two LogDebug() calls. In addrman.cpp, a missing collision entry previously logged an empty string; it now logs ‘
Changed components
src/addrman.cpp debug loggingsrc/net_processing.cpp debug loggingInspect captured patch +4 / −4
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 2e514909..398c51b3 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -663,8 +663,8 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, NodeSecond
}
// Output the entry we'd be colliding with, for debugging purposes
auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
- LogDebug(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
- colliding_entry != mapInfo.end() ? colliding_entry->second.ToStringAddrPort() : "",
+ LogDebug(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d",
+ colliding_entry != mapInfo.end() ? colliding_entry->second.ToStringAddrPort() : "<unknown-addr>",
addr.ToStringAddrPort(),
m_tried_collisions.size());
return false;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index e5b4bc77..b79c4224 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3669,8 +3669,8 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
}
const auto mapped_as{m_connman.GetMappedAS(pfrom.addr)};
- LogDebug(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d%s%s\n",
- cleanSubVer, pfrom.nVersion,
+ LogDebug(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, txrelay=%d, peer=%d%s%s",
+ cleanSubVer.empty() ? "<no user agent>" : cleanSubVer, pfrom.nVersion,
peer.m_starting_height, addrMe.ToStringAddrPort(), fRelay, pfrom.GetId(),
pfrom.LogIP(fLogIPs), (mapped_as ? strprintf(", mapped_as=%d", mapped_as) : ""));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.