From 1f06cad15da1b6ec46dbfbdbcb650577922bb941 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 7 Oct 2018 22:32:27 +0100 Subject: DS: Fix Out Of Bounds Array Access Errors. This is from bug Trac #10653. --- backends/platform/ds/arm9/source/fat/gba_nds_fat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c index 76508a1664..1247b3f948 100644 --- a/backends/platform/ds/arm9/source/fat/gba_nds_fat.c +++ b/backends/platform/ds/arm9/source/fat/gba_nds_fat.c @@ -1460,7 +1460,7 @@ DIR_ENT FAT_DirEntFromPath (const char* path) { // Match filename found = true; - for (namePos = 0; (namePos < MAX_FILENAME_LENGTH) && found && (name[namePos] != '\0') && (lfnName[namePos] != '\0'); namePos++) + for (namePos = 0; (namePos < MAX_FILENAME_LENGTH-1) && found && (name[namePos] != '\0') && (lfnName[namePos] != '\0'); namePos++) { if (name[namePos] != ucase(lfnName[namePos])) { @@ -1477,7 +1477,7 @@ DIR_ENT FAT_DirEntFromPath (const char* path) { FAT_GetFilename(dirEntry, alias); found = true; - for (namePos = 0; (namePos < 13) && found && (name[namePos] != '\0') && (alias[namePos] != '\0'); namePos++) + for (namePos = 0; (namePos < (sizeof(alias)/sizeof(alias[0]))-1) && found && (name[namePos] != '\0') && (alias[namePos] != '\0'); namePos++) { if (name[namePos] != ucase(alias[namePos])) { @@ -3186,7 +3186,7 @@ int FAT_mkdir (const char* path) // Create . directory entry dirEntry.name[0] = '.'; // Fill name and extension with spaces - for (i = 1; i < 11; i++) + for (i = 1; i < (sizeof(name)/sizeof(name[0])); i++) { dirEntry.name[i] = ' '; } -- cgit v1.2.3