Skip to content

Commit 36f8e99

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24218: zmq: Fix implicit-integer-sign-change
fa2406a zmq: Fix implicit-integer-sign-change (MarcoFalke) Pull request description: uint256::begin() returns unsigned data, so there is no reason to make it signed. Fix that and remove the sanitizer suppression. ACKs for top commit: hebasto: ACK fa2406a PastaPastaPasta: utACK fa2406a, I have reviewed the code and think it makes sense Tree-SHA512: 150ebcf3fdc3e0f60b6fd8e5fe638737b01e8a0863296bd545fb5ed17d33ab23b2ff94204996aa7b4617650b7383bd86ed2d2bf46746b410feae449de179a2bd
2 parents fcac16f + fa2406a commit 36f8e99

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/zmq/zmqpublishnotifier.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,21 @@ bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
209209
{
210210
uint256 hash = pindex->GetBlockHash();
211211
LogPrint(BCLog::ZMQ, "zmq: Publish hashblock %s to %s\n", hash.GetHex(), this->address);
212-
char data[32];
213-
for (unsigned int i = 0; i < 32; i++)
212+
uint8_t data[32];
213+
for (unsigned int i = 0; i < 32; i++) {
214214
data[31 - i] = hash.begin()[i];
215+
}
215216
return SendZmqMessage(MSG_HASHBLOCK, data, 32);
216217
}
217218

218219
bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &transaction)
219220
{
220221
uint256 hash = transaction.GetHash();
221222
LogPrint(BCLog::ZMQ, "zmq: Publish hashtx %s to %s\n", hash.GetHex(), this->address);
222-
char data[32];
223-
for (unsigned int i = 0; i < 32; i++)
223+
uint8_t data[32];
224+
for (unsigned int i = 0; i < 32; i++) {
224225
data[31 - i] = hash.begin()[i];
226+
}
225227
return SendZmqMessage(MSG_HASHTX, data, 32);
226228
}
227229

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ implicit-integer-sign-change:script/bitcoinconsensus.cpp
7272
implicit-integer-sign-change:script/interpreter.cpp
7373
implicit-integer-sign-change:serialize.h
7474
implicit-integer-sign-change:txmempool.cpp
75-
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
7675
implicit-signed-integer-truncation:addrman.cpp
7776
implicit-signed-integer-truncation:addrman.h
7877
implicit-signed-integer-truncation:crypto/

0 commit comments

Comments
 (0)