Scripts/Commands: Fix issues reported by static analysis
Fix possible buffer overflow in ".server shutdown" and NULL-dereference/Triggered Debug Assert.
This commit is contained in:
1 parent
25f75501ef
commit
29b9e5f0d5
1 file changed
+9
-6
@@ -316,6 +316,9 @@ private:
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
if (strlen(args) > 255)
|
||||
return false;
|
||||
|
||||
// #delay [#exit_code] [reason]
|
||||
char* delayStr = strtok((char*)args, " ");
|
||||
if (!delayStr || !isNumeric(delayStr))
|
||||
@@ -323,10 +326,7 @@ private:
|
||||
|
||||
char* exitCodeStr = nullptr;
|
||||
|
||||
if (strlen(args) > 255)
|
||||
return false;
|
||||
|
||||
char reason[255] = { 0 };
|
||||
char reason[256] = { 0 };
|
||||
|
||||
while (char* nextToken = strtok(nullptr, " "))
|
||||
{
|
||||
@@ -335,8 +335,11 @@ private:
|
||||
else
|
||||
{
|
||||
strcat(reason, nextToken);
|
||||
strcat(reason, " ");
|
||||
strcat(reason, strtok(nullptr, "\0"));
|
||||
if (char* remainingTokens = strtok(nullptr, "\0"))
|
||||
{
|
||||
strcat(reason, " ");
|
||||
strcat(reason, remainingTokens);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user