0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

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
This commit is contained in:
Richard Stanway 2021-04-04 23:09:14 +02:00
parent 31c488f0d0
commit 4c8b209bf0

View File

@ -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;