Skip to content

Commit

Permalink
Merge pull request #835 from devnexen/cmd_buffer_overflow
Browse files Browse the repository at this point in the history
cmd buffer overflow proposal.
  • Loading branch information
bradharding authored Aug 21, 2024
2 parents f894416 + dd53514 commit d425f4a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,11 @@ void M_LoadCVARs(const char *filename)
{
char *temp = Z_StringDuplicate(value + 1, PU_STATIC, NULL);

temp[strlen(temp) - 1] = '\0';
temp[consolecmds[C_GetIndex(cvar)].length] = '\0';
size_t length = strlen(temp) - 1;
size_t cmdlength = (size_t)consolecmds[C_GetIndex(cvar)].length;
temp[length] = '\0';
if (cmdlength < length)
temp[cmdlength] = '\0';
*(char **)cvars[i].location = temp;
cvarcount++;
break;
Expand Down

0 comments on commit d425f4a

Please sign in to comment.