From 576999ef84a08939ba67cb15ee904d80050be3b6 Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 14 Oct 2025 11:11:12 -0400 Subject: Fix overflows inserting invalid values into stats map Signed-off-by: Rye --- indra/llcommon/llsys.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llsys.cpp') diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 32f577fbe0..8512ace9e1 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -713,7 +713,7 @@ public: void add(const LLSD::String& name, const T& value, typename boost::enable_if >::type* = 0) { - mStats[name] = LLSD::Integer(value); + mStats[name] = LLSD::Integer(llmin(value, S32_MAX)); } // Store every floating-point type as LLSD::Real. @@ -1112,9 +1112,10 @@ LLSD LLMemoryInfo::loadStatsMap() LLSD::String key(matched[1].first, matched[1].second); LLSD::String value_str(matched[2].first, matched[2].second); LLSD::Integer value(0); + S64 intval = 0; try { - value = boost::lexical_cast(value_str); + intval = llclamp(boost::lexical_cast(value_str), S32_MIN, S32_MAX); } catch (const boost::bad_lexical_cast&) { @@ -1123,6 +1124,7 @@ LLSD LLMemoryInfo::loadStatsMap() << line << LL_ENDL; continue; } + value = LLSD::Integer(intval); // Store this statistic. stats.add(key, value); } -- cgit v1.3