From: Devansh-567 Date: Fri, 26 Jun 2026 07:27:53 +0000 (+0530) Subject: Validate unsigned integer JSON config values X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0707cc6c457da404a55040277c8ff3c139e33132;p=thirdparty%2Fsnapper.git Validate unsigned integer JSON config values --- 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; }