diff options
| author | Rye <rye@alchemyviewer.org> | 2025-10-14 11:11:12 -0400 |
|---|---|---|
| committer | Rye <rye@alchemyviewer.org> | 2025-10-27 04:59:14 -0400 |
| commit | 576999ef84a08939ba67cb15ee904d80050be3b6 (patch) | |
| tree | 988eb7bc09ec574256437dff3ff080cbd7e6afa7 /indra/llcommon/llsys.cpp | |
| parent | 58ffc5f96091cc72f213290afebb2dc1a0048ea5 (diff) | |
Fix overflows inserting invalid values into stats map
Signed-off-by: Rye <rye@alchemyviewer.org>
Diffstat (limited to 'indra/llcommon/llsys.cpp')
| -rw-r--r-- | indra/llcommon/llsys.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<boost::is_integral<T> >::type* = 0) { - mStats[name] = LLSD::Integer(value); + mStats[name] = LLSD::Integer(llmin<T>(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<LLSD::Integer>(value_str); + intval = llclamp(boost::lexical_cast<S64>(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); } |
