From 2e9bc3494f62761660e6ae9b5cc6caa0e170ca9a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 8 Jun 2022 14:02:48 +0200 Subject: [PATCH] QLocale: use qsnprintf instead of deprecated sprintf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes warnings such as qtbase/src/corelib/text/qlocale_tools.cpp:321:5: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] from AppleClang. Pick-to: 6.4 6.3 Change-Id: Ief10e99abfa0a56c24622ac79db719dde58a4210 Reviewed-by: Tor Arne Vestbø --- src/corelib/text/qlocale_tools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index 6964550b2d..2419cb4e29 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -318,7 +318,7 @@ double qt_asciiToDouble(const char *num, qsizetype numLen, bool &ok, int &proces constexpr auto maxDigitsForULongLong = 1 + std::numeric_limits::digits10; // need to ensure that we don't read more than numLen of input: char fmt[1 + maxDigitsForULongLong + 4 + 1]; - sprintf(fmt, "%s%llu%s", "%", static_cast(numLen), "lf%n"); + qsnprintf(fmt, sizeof fmt, "%s%llu%s", "%", static_cast(numLen), "lf%n"); if (qDoubleSscanf(num, QT_CLOCALE, fmt, &d, &processed) < 1) processed = 0;