From 4c8b209bf08d4fe3722a3208fe84ce339864d6f2 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Sun, 4 Apr 2021 23:09:14 +0200 Subject: [PATCH] UI: Use larger buffer for scene collection filename Though the maximum size of a scene name is 170 characters, after worst-case UTF-8 expansion this could overflow the buffer, resulting in the scene collection being "lost" as the .json extension was truncated. Fixes #2560 --- UI/window-basic-main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 54e1002a8..8f4040601 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1723,15 +1723,15 @@ void OBSBasic::OBSInit() const char *sceneCollection = config_get_string( App()->GlobalConfig(), "Basic", "SceneCollectionFile"); - char savePath[512]; - char fileName[512]; + char savePath[1024]; + char fileName[1024]; int ret; if (!sceneCollection) throw "Failed to get scene collection name"; - ret = snprintf(fileName, 512, "obs-studio/basic/scenes/%s.json", - sceneCollection); + ret = snprintf(fileName, sizeof(fileName), + "obs-studio/basic/scenes/%s.json", sceneCollection); if (ret <= 0) throw "Failed to create scene collection file name"; @@ -2717,15 +2717,16 @@ void OBSBasic::SaveProjectDeferred() const char *sceneCollection = config_get_string( App()->GlobalConfig(), "Basic", "SceneCollectionFile"); - char savePath[512]; - char fileName[512]; + + char savePath[1024]; + char fileName[1024]; int ret; if (!sceneCollection) return; - ret = snprintf(fileName, 512, "obs-studio/basic/scenes/%s.json", - sceneCollection); + ret = snprintf(fileName, sizeof(fileName), + "obs-studio/basic/scenes/%s.json", sceneCollection); if (ret <= 0) return;