Add bounds checking
This commit is contained in:
parent
2fe1169423
commit
ff86ed2e77
@ -887,13 +887,13 @@ static Result Cheat_ReadLine(char* line, u32 lineSize)
|
|||||||
|
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
u32 idx = 0;
|
u32 idx = 0;
|
||||||
while (R_SUCCEEDED(res))
|
while (R_SUCCEEDED(res) && cheatFilePos < sizeof(cheatFileBuffer))
|
||||||
{
|
{
|
||||||
c = cheatFileBuffer[cheatFilePos++];
|
c = cheatFileBuffer[cheatFilePos++];
|
||||||
res = c ? 0 : -1;
|
res = c ? 0 : -1;
|
||||||
if (R_SUCCEEDED(res) && c != '\0')
|
if (R_SUCCEEDED(res) && c != '\0')
|
||||||
{
|
{
|
||||||
if (c == '\r' && cheatFileBuffer[cheatFilePos] == '\n')
|
if (c == '\r' && cheatFilePos < sizeof(cheatFileBuffer) && cheatFileBuffer[cheatFilePos] == '\n')
|
||||||
{
|
{
|
||||||
cheatFilePos++;
|
cheatFilePos++;
|
||||||
line[idx++] = '\0';
|
line[idx++] = '\0';
|
||||||
|
Reference in New Issue
Block a user