Avoid strlen; use strnlen

This commit is contained in:
Pieter Wuille 2021-01-14 19:04:26 -08:00
parent 0df0e521f1
commit a39d7916d0

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;