From ae01a626b6681e9dd52621877b8a71ec6ef00580 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Thu, 28 Jul 2022 20:18:20 +0200 Subject: [PATCH] linux-capture: Replace invocations of sprintf with snprintf Fixes deprecation warnings in Xcode 14/clang on macOS and reduces chance of buffer overflows. --- plugins/linux-capture/xshm-input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/linux-capture/xshm-input.c b/plugins/linux-capture/xshm-input.c index c57d19bf7..1e59cb898 100644 --- a/plugins/linux-capture/xshm-input.c +++ b/plugins/linux-capture/xshm-input.c @@ -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; }