Browse Source

Prevent a buffer overflow in diveToFile

Co-Authored-By: akunt
Scott Lahteine 6 years ago
parent
commit
c2bdbdffaa
1 changed files with 1 additions and 2 deletions
  1. 1
    2
      Marlin/src/sd/cardreader.cpp

+ 1
- 2
Marlin/src/sd/cardreader.cpp View File

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

Loading…
Cancel
Save