File spdlog-CVE-2025-6140.patch of Package spdlog.18996
From 10320184df1eb4638e253a34b1eb44ce78954094 Mon Sep 17 00:00:00 2001
From: Gabi Melman <gmelman1@gmail.com>
Date: Mon, 17 Mar 2025 15:46:31 +0200
Subject: [PATCH] Fixed issue #3360 (#3361)
---
include/spdlog/pattern_formatter-inl.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Index: spdlog-1.12.0/include/spdlog/pattern_formatter-inl.h
===================================================================
--- spdlog-1.12.0.orig/include/spdlog/pattern_formatter-inl.h
+++ spdlog-1.12.0/include/spdlog/pattern_formatter-inl.h
@@ -76,6 +76,9 @@ public:
else if (padinfo_.truncate_)
{
long new_size = static_cast<long>(dest_.size()) + remaining_pad_;
+ if (new_size < 0) {
+ new_size = 0;
+ }
dest_.resize(static_cast<size_t>(new_size));
}
}
@@ -303,7 +306,7 @@ public:
void format(const details::log_msg &, const std::tm &tm_time, memory_buf_t &dest) override
{
- const size_t field_size = 10;
+ const size_t field_size = 8;
ScopedPadder p(field_size, padinfo_, dest);
fmt_helper::pad2(tm_time.tm_mon + 1, dest);