From 048735114b973ae987a18b8ded8d52ea2f11e722 Mon Sep 17 00:00:00 2001 From: staphen Date: Tue, 26 Oct 2021 11:54:39 -0400 Subject: [PATCH] Prevent buffer overruns due to oversized INI values --- Source/options.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/options.cpp b/Source/options.cpp index f3f48bf96..ead1ef93d 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -204,7 +204,8 @@ bool GetIniValue(const char *sectionName, const char *keyName, char *string, int strncpy(string, defaultString, stringSize); return false; } - strncpy(string, value, stringSize); + strncpy(string, value, stringSize - 1); + string[stringSize - 1] = '\0'; return true; }