Merge #89: Avoid strlen; use strnlen

a39d7916d0 Avoid strlen; use strnlen (Pieter Wuille)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 4e60f2aece7e83635ea0db6adf623472649a05d4b69f3700cae4fb94e2e937503774a332d7bae794f59261d5fd62e3679db9cdd704c31e5350ffb5b9f1b6c51f
This commit is contained in:
Pieter Wuille 2021-01-15 13:32:49 -08:00
commit a09d2870d1
No known key found for this signature in database
GPG key ID: A636E97631F767E0

View file

@ -36,7 +36,7 @@ CMessageHeader::CMessageHeader()
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
{
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
int command_len = strlen(pszCommand);
size_t command_len = strnlen(pszCommand, COMMAND_SIZE);
memcpy(pchCommand, pszCommand, command_len);
memset(pchCommand + command_len, 0, COMMAND_SIZE - command_len);
nMessageSize = nMessageSizeIn;