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 committed 2022-11-11 19:51:27 +01:00
1 parent c257c29084
commit ae01a626b6
1 file changed
+7 -1
+7 -1
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;
}