1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 13:25:54 +00:00

Prevent a buffer overflow in cardreader

This commit is contained in:
Alex 2018-06-03 13:32:40 +02:00 committed by Scott Lahteine
parent 3be22fc1fc
commit 3bc392f592

View File

@ -582,9 +582,8 @@ const char* CardReader::diveToFile(SdFile*& curDir, const char * const path, con
while (dirname_start) {
char * const dirname_end = strchr(dirname_start, '/');
if (dirname_end <= dirname_start) break;
char dosSubdirname[FILENAME_LENGTH];
const uint8_t len = dirname_end - dirname_start;
char dosSubdirname[len + 1];
strncpy(dosSubdirname, dirname_start, len);
dosSubdirname[len] = 0;