From 0707cc6c457da404a55040277c8ff3c139e33132 Mon Sep 17 00:00:00 2001 From: Devansh-567 Date: Fri, 26 Jun 2026 12:57:53 +0530 Subject: [PATCH] Validate unsigned integer JSON config values --- client/snbk/JsonFile.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/snbk/JsonFile.cc b/client/snbk/JsonFile.cc index 0a40d6df..4cfd3c0b 100644 --- a/client/snbk/JsonFile.cc +++ b/client/snbk/JsonFile.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "snapper/Exception.h" #include "snapper/AppUtil.h" @@ -181,7 +182,13 @@ namespace snapper if (!json_object_is_type(child, json_type_int) && !json_object_is_type(child, json_type_string)) return false; - value = json_object_get_int(child); + int64_t val64 = json_object_get_int64(child); + if (val64 < 0 || val64 > std::numeric_limits::max()) + { + SN_THROW(Exception(sformat("Value out of bounds for unsigned int key '%s'", name))); + } + + value = (unsigned int)val64; return true; } -- 2.47.3