From 4b1369e85991f9754aff95c2a593f7fc1ecb1974 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 17 May 2022 02:37:32 +0200 Subject: [PATCH] Make sure MAX_OSPATH has sane size --- framework/FileSystem.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/FileSystem.h b/framework/FileSystem.h index 529ed5b..7692e55 100644 --- a/framework/FileSystem.h +++ b/framework/FileSystem.h @@ -59,7 +59,10 @@ If you have questions concerning this license or the applicable additional terms static const ID_TIME_T FILE_NOT_FOUND_TIMESTAMP = 0xFFFFFFFF; static const int MAX_PURE_PAKS = 128; -static const int MAX_OSPATH = FILENAME_MAX; +// DG: https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html says +// that FILENAME_MAX can be *really* big on some systems and thus is not suitable +// for buffer lengths. So limit it to prevent stack overflow/out of memory issues +static const int MAX_OSPATH = (FILENAME_MAX < 32000) ? FILENAME_MAX : 32000; // modes for OpenFileByMode. used as bit mask internally typedef enum {