瀏覽代碼

Fix lsDive filename stack overrun (PR#2449)

Scott Lahteine 9 年之前
父節點
當前提交
552a327df8
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2
    2
      Marlin/cardreader.cpp

+ 2
- 2
Marlin/cardreader.cpp 查看文件

@@ -56,8 +56,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
56 56
     // If the entry is a directory and the action is LS_SerialPrint
57 57
     if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
58 58
 
59
-      // Allocate enough stack space for the full path to a folder
60
-      int len = strlen(prepend) + FILENAME_LENGTH + 1;
59
+      // Allocate enough stack space for the full path to a folder, trailing slash, and nul
60
+      int len = strlen(prepend) + FILENAME_LENGTH + 1 + 1;
61 61
       char path[len];
62 62
 
63 63
       // Get the short name for the item, which we know is a folder

Loading…
取消
儲存