From 9bd4514b45a8150328190cd6bc3d2dbf00ebfd3b Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Tue, 27 May 2025 14:51:44 -0400 Subject: [PATCH] frontend: Ensure cookie ID is always 16 hexadecimal characters At a glance, the GenId function looks like it can only return a 16-character hexadecimal string with all characters being [0-9A-F]. However, it seems that it can rarely return a 16-character string that has one or two space characters at the beginning due to the value of id, from which the final string is derived, being too low (lower than 1152921504606846976 or 0x1000000000000000) and the printf format specifier having a width of 16. This results in a string of less than 16 characters that is padded with blank spaces. The end result is a cookie directory that has leading spaces in its name, which can cause various issues, such as breaking syncing on OneDrive. If we set the format specifier to pad with zeroes instead of spaces, the resulting hexadecimal value is always 16 characters long without spaces. --- frontend/widgets/OBSBasic_Browser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/widgets/OBSBasic_Browser.cpp b/frontend/widgets/OBSBasic_Browser.cpp index cfcf6b42d..ecac24957 100644 --- a/frontend/widgets/OBSBasic_Browser.cpp +++ b/frontend/widgets/OBSBasic_Browser.cpp @@ -169,7 +169,7 @@ static std::string GenId() uint64_t id = dist(e2); char id_str[20]; - snprintf(id_str, sizeof(id_str), "%16llX", (unsigned long long)id); + snprintf(id_str, sizeof(id_str), "%016llX", (unsigned long long)id); return std::string(id_str); }