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

linux-capture: Replace invocations of sprintf with snprintf

Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
This commit is contained in:
PatTheMav 2022-07-28 20:18:20 +02:00
parent c257c29084
commit ae01a626b6
No known key found for this signature in database

View File

@ -365,7 +365,13 @@ static bool xshm_server_changed(obs_properties_t *props, obs_property_t *p,
x11_screen_geo(xcb, i, &w, &h);
if (name == NULL) {
sprintf(name_tmp, "%" PRIuFAST32, i);
int ret = snprintf(name_tmp, sizeof(name_tmp),
"%" PRIuFAST32, i);
if (ret >= sizeof(name_tmp))
blog(LOG_DEBUG,
"linux-capture: A format truncation may have occurred."
" This can be ignored since it is quite improbable.");
name = name_tmp;
}