From 552a327df89ca4db82521839effcc7e7d8846902 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Wed, 15 Jul 2015 17:06:29 -0700
Subject: [PATCH] Fix lsDive filename stack overrun (PR#2449)

---
 Marlin/cardreader.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp
index 8693424d30..b8a940f4ba 100644
--- a/Marlin/cardreader.cpp
+++ b/Marlin/cardreader.cpp
@@ -56,8 +56,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
     // If the entry is a directory and the action is LS_SerialPrint
     if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
 
-      // Allocate enough stack space for the full path to a folder
-      int len = strlen(prepend) + FILENAME_LENGTH + 1;
+      // Allocate enough stack space for the full path to a folder, trailing slash, and nul
+      int len = strlen(prepend) + FILENAME_LENGTH + 1 + 1;
       char path[len];
 
       // Get the short name for the item, which we know is a folder
-- 
GitLab