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
   while (dirname_start) {
622
   while (dirname_start) {
623
     char * const dirname_end = strchr(dirname_start, '/');
623
     char * const dirname_end = strchr(dirname_start, '/');
624
     if (dirname_end <= dirname_start) break;
624
     if (dirname_end <= dirname_start) break;
625
-
626
-    char dosSubdirname[FILENAME_LENGTH];
627
     const uint8_t len = dirname_end - dirname_start;
625
     const uint8_t len = dirname_end - dirname_start;
626
+    char dosSubdirname[len + 1];
628
     strncpy(dosSubdirname, dirname_start, len);
627
     strncpy(dosSubdirname, dirname_start, len);
629
     dosSubdirname[len] = 0;
628
     dosSubdirname[len] = 0;
630
 
629
 

Loading…
Cancel
Save