Page MenuHomePhabricator

[backport#16995] net: Fail instead of truncate command name in CMessageHeader
ClosedPublic

Authored by majcosta on May 20 2020, 14:41.

Details

Summary

Replace the memset/strncpy dance in CMessageHeader::CMessageHeader
with explicit code that copies then name and asserts the length.

This removes a warning in g++ 9.1.1 and IMO makes the code more readable
by not relying on strncpy padding and silent truncation behavior.

https://github.com/bitcoin/bitcoin/pull/16995/commits/b837b334db5dd6232725fd2350928ff4fbd3feee


This is a partial backport of Core PR16995

Test Plan
ninja check

Event Timeline

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

jasonbcox added a subscriber: jasonbcox.
jasonbcox added inline comments.
src/protocol.h
53

Nit: newline after /**

This revision is now accepted and ready to land.May 20 2020, 17:30