test, refactor: Fix `-Warray-bounds` warning
What changed, and why it matters
This is a one-line change inside a test file that removes a compiler warning. It swaps a pointer cast to char* for a direct iterator-based copy when building fake network message data for unit tests. There is no change to production code and no security-relevant behavior change.
No security action needed. Treat as normal code-quality/test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/test/net_tests.cpp, the patch replaces reinterpret_cast
Changed components
src/test/net_tests.cppInspect captured patch +1 / −1
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 711b067a..a2ff9a10 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -1301,7 +1301,7 @@ public:
{
// Construct contents consisting of 0x00 + 12-byte message type + payload.
std::vector<uint8_t> contents(1 + CMessageHeader::MESSAGE_TYPE_SIZE + payload.size());
- std::copy(mtype.begin(), mtype.end(), reinterpret_cast<char*>(contents.data() + 1));
+ std::copy(mtype.begin(), mtype.end(), contents.begin() + 1);
std::copy(payload.begin(), payload.end(), contents.begin() + 1 + CMessageHeader::MESSAGE_TYPE_SIZE);
// Send a packet with that as contents.
SendPacket(contents);
Why this scored 13/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.