From 10320184df1eb4638e253a34b1eb44ce78954094 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Mon, 17 Mar 2025 15:46:31 +0200 Subject: [PATCH] Fixed issue #3360 (#3361) Backport of upstream commit 10320184df1eb4638e253a34b1eb44ce78954094 for spdlog 1.11.0 (CVE-2025-6140, allocation-size-too-big in scoped_padder). Only the scoped_padder fix is kept. The unrelated field_size change (D_formatter) and whitespace cleanup from the original upstream commit are intentionally dropped, since they are not part of this CVE's fix and would alter unrelated behavior. --- include/spdlog/pattern_formatter-inl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/spdlog/pattern_formatter-inl.h b/include/spdlog/pattern_formatter-inl.h --- a/include/spdlog/pattern_formatter-inl.h +++ b/include/spdlog/pattern_formatter-inl.h @@ -76,6 +76,10 @@ else if (padinfo_.truncate_) { long new_size = static_cast(dest_.size()) + remaining_pad_; + if (new_size < 0) + { + new_size = 0; + } dest_.resize(static_cast(new_size)); } }