HomePhabricator

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

Authored by Wladimir J. van der Laan <laanwj@protonmail.com> on Sep 30 2019, 10:27.

Description

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

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

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D6164

Details

Committed
majcostaMay 20 2020, 18:19
Pushed
abc-botMay 20 2020, 18:20
Reviewer
Restricted Project
Differential Revision
D6164: [backport#16995] net: Fail instead of truncate command name in CMessageHeader
Parents
rSTAGING30b314cb2e35: [backport#15195] interfaces: Add remove to Wallet
Branches
Unknown
Tags
Unknown