port: fix -Wdeprecated-declarations warning about sprintf on macOS clang 14
[babeltrace.git] / src / common / common.c
index 85920c10b4525de2b96e66b0243a7c915c18882f..aca73e5fb757b47a84717612a3a4fc8b41b06095 100644 (file)
@@ -27,6 +27,7 @@
 #include "common/macros.h"
 #include "common/common.h"
 #include "compat/unistd.h"
+#include "compat/limits.h"
 
 #ifndef __MINGW32__
 #include <pwd.h>
@@ -2040,7 +2041,7 @@ int bt_common_g_string_append_printf(GString *str, const char *fmt, ...)
                /* Resize. */
                g_string_set_size(str, len + print_len);
                va_start(ap, fmt);
-               print_len = vsprintf(str->str + len, fmt, ap);
+               print_len = vsnprintf(str->str + len, print_len + 1, fmt, ap);
                va_end(ap);
        } else {
                str->len = len + print_len;
This page took 0.023033 seconds and 4 git commands to generate.