Avoid strncpy for commands
This commit is contained in:
parent
89929dab5c
commit
24e1cac582
1 changed files with 3 additions and 1 deletions
|
@ -36,7 +36,9 @@ CMessageHeader::CMessageHeader()
|
||||||
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
|
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
|
||||||
{
|
{
|
||||||
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
|
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
|
||||||
strncpy(pchCommand, pszCommand, COMMAND_SIZE);
|
int command_len = strlen(pszCommand);
|
||||||
|
memcpy(pchCommand, pszCommand, command_len);
|
||||||
|
memset(pchCommand + command_len, 0, COMMAND_SIZE - command_len);
|
||||||
nMessageSize = nMessageSizeIn;
|
nMessageSize = nMessageSizeIn;
|
||||||
nChecksum = 0;
|
nChecksum = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue