Skip to content

Commit

Permalink
Fix warning on strncpy
Browse files Browse the repository at this point in the history
  • Loading branch information
atupone committed Sep 8, 2024
1 parent e43ddb6 commit c0acf21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/game/PlayerInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void PlayerInfo::setCallSign(const char * c)
{
if (c != NULL)
{
strncpy(callSign, c, CallSignLen);
strncpy(callSign, c, CallSignLen - 1);
callSign[CallSignLen - 1] = '\0'; // ensure null termination
}
}
Expand Down Expand Up @@ -366,7 +366,7 @@ bool PlayerInfo::isMottoReadable()

void PlayerInfo::setMotto(const char* _motto)
{
strncpy(motto, _motto, MottoLen);
strncpy(motto, _motto, MottoLen - 1);
motto[MottoLen - 1] = '\0'; // ensure null termination
}

Expand All @@ -379,7 +379,7 @@ void PlayerInfo::setToken(const char * c)
{
if (c != NULL)
{
strncpy(token, c, TokenLen);
strncpy(token, c, TokenLen - 1);
token[TokenLen - 1] = '\0'; // ensure null termination
}
}
Expand Down Expand Up @@ -457,7 +457,7 @@ void PlayerInfo::setClientVersion(const char * c)
{
if (c != NULL)
{
strncpy(clientVersion, c, VersionLen);
strncpy(clientVersion, c, VersionLen - 1);
clientVersion[VersionLen - 1] = '\0'; // ensure null termination
}
}
Expand Down

0 comments on commit c0acf21

Please sign in to comment.