From 887054a70b9af6a75f462c37e572e3d68e7f9127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Plewa?= Date: Wed, 25 Oct 2023 16:29:31 +0200 Subject: [PATCH] Fix infinite loop in logger. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When there where was more arguments then "{}" in the format string program hanged up due to infinite loop in format function. Signed-off-by: Ɓukasz Plewa --- source/common/logger/ur_sinks.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/common/logger/ur_sinks.hpp b/source/common/logger/ur_sinks.hpp index 01362828b5..31b882f80c 100644 --- a/source/common/logger/ur_sinks.hpp +++ b/source/common/logger/ur_sinks.hpp @@ -110,6 +110,14 @@ class Sink { << std::endl; } } + + if (*fmt == '\0') { + std::cerr << error_prefix + << "Too many arguments!" << std::endl; + // ignore all left arguments and finalize message + format(buffer, fmt); + return; + } } format(buffer, ++fmt, std::forward(args)...);