Merge pull request #4940
62e5f8f
CMessageHeader sanity changes (Wladimir J. van der Laan)
This commit is contained in:
commit
1fbccda8d0
1 changed files with 2 additions and 5 deletions
|
@ -24,7 +24,6 @@ CMessageHeader::CMessageHeader()
|
||||||
{
|
{
|
||||||
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
|
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
|
||||||
memset(pchCommand, 0, sizeof(pchCommand));
|
memset(pchCommand, 0, sizeof(pchCommand));
|
||||||
pchCommand[1] = 1;
|
|
||||||
nMessageSize = -1;
|
nMessageSize = -1;
|
||||||
nChecksum = 0;
|
nChecksum = 0;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +31,7 @@ CMessageHeader::CMessageHeader()
|
||||||
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
|
CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
|
||||||
{
|
{
|
||||||
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
|
memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE);
|
||||||
|
memset(pchCommand, 0, sizeof(pchCommand));
|
||||||
strncpy(pchCommand, pszCommand, COMMAND_SIZE);
|
strncpy(pchCommand, pszCommand, COMMAND_SIZE);
|
||||||
nMessageSize = nMessageSizeIn;
|
nMessageSize = nMessageSizeIn;
|
||||||
nChecksum = 0;
|
nChecksum = 0;
|
||||||
|
@ -39,10 +39,7 @@ CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSize
|
||||||
|
|
||||||
std::string CMessageHeader::GetCommand() const
|
std::string CMessageHeader::GetCommand() const
|
||||||
{
|
{
|
||||||
if (pchCommand[COMMAND_SIZE-1] == 0)
|
return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE));
|
||||||
return std::string(pchCommand, pchCommand + strlen(pchCommand));
|
|
||||||
else
|
|
||||||
return std::string(pchCommand, pchCommand + COMMAND_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMessageHeader::IsValid() const
|
bool CMessageHeader::IsValid() const
|
||||||
|
|
Loading…
Reference in a new issue