From 9c891b64ffd14bc8216dbd5eb60816043af265b6 Mon Sep 17 00:00:00 2001 From: eugene Date: Tue, 11 May 2021 11:21:29 -0400 Subject: [PATCH] net: initialize nMessageSize to max uint32_t instead of -1 nMessageSize is uint32_t and is set to -1. This will warn with -fsanitize=implicit-integer-sign-change. --- src/protocol.cpp | 1 - src/protocol.h | 3 ++- test/sanitizer_suppressions/ubsan | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/protocol.cpp b/src/protocol.cpp index 0b893b9272..2f77ec18e6 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -91,7 +91,6 @@ CMessageHeader::CMessageHeader() { memset(pchMessageStart, 0, MESSAGE_START_SIZE); memset(pchCommand, 0, sizeof(pchCommand)); - nMessageSize = -1; memset(pchChecksum, 0, CHECKSUM_SIZE); } diff --git a/src/protocol.h b/src/protocol.h index f183db0501..c73484bdf6 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -51,7 +52,7 @@ public: char pchMessageStart[MESSAGE_START_SIZE]; char pchCommand[COMMAND_SIZE]; - uint32_t nMessageSize; + uint32_t nMessageSize{std::numeric_limits::max()}; uint8_t pchChecksum[CHECKSUM_SIZE]; }; diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index b66ca00376..4f6f92bd3c 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -62,7 +62,6 @@ implicit-integer-sign-change:key.cpp implicit-integer-sign-change:noui.cpp implicit-integer-sign-change:policy/fees.cpp implicit-integer-sign-change:prevector.h -implicit-integer-sign-change:protocol.cpp implicit-integer-sign-change:script/bitcoinconsensus.cpp implicit-integer-sign-change:script/interpreter.cpp implicit-integer-sign-change:serialize.h