From ff86ed2e77c3d94b60e5421d66c9234e1c0e322a Mon Sep 17 00:00:00 2001 From: piepie62 Date: Mon, 15 Apr 2019 03:41:25 -0700 Subject: [PATCH] Add bounds checking --- sysmodules/rosalina/source/menus/cheats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysmodules/rosalina/source/menus/cheats.c b/sysmodules/rosalina/source/menus/cheats.c index e32d321..5adfe4b 100644 --- a/sysmodules/rosalina/source/menus/cheats.c +++ b/sysmodules/rosalina/source/menus/cheats.c @@ -887,13 +887,13 @@ static Result Cheat_ReadLine(char* line, u32 lineSize) char c = '\0'; u32 idx = 0; - while (R_SUCCEEDED(res)) + while (R_SUCCEEDED(res) && cheatFilePos < sizeof(cheatFileBuffer)) { c = cheatFileBuffer[cheatFilePos++]; res = c ? 0 : -1; if (R_SUCCEEDED(res) && c != '\0') { - if (c == '\r' && cheatFileBuffer[cheatFilePos] == '\n') + if (c == '\r' && cheatFilePos < sizeof(cheatFileBuffer) && cheatFileBuffer[cheatFilePos] == '\n') { cheatFilePos++; line[idx++] = '\0';