]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-json: fix sd_json_variant_unsigned() dispatching to wrong accessor for references 41529/head
authorChristian Brauner <brauner@kernel.org>
Wed, 1 Apr 2026 21:23:18 +0000 (23:23 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 6 Apr 2026 20:02:54 +0000 (22:02 +0200)
sd_json_variant_unsigned() incorrectly calls sd_json_variant_integer()
for reference-type variants instead of recursing to itself. This silently
returns 0 for unsigned values in the range INT64_MAX+1 through
UINT64_MAX, since sd_json_variant_integer() cannot represent them.

The sibling functions sd_json_variant_integer() and
sd_json_variant_real() correctly recurse to themselves.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
src/libsystemd/sd-json/sd-json.c

index 03557d3ac682226ca2d5e4f4a366b4adaf36a055..6245d471b7a6fb13472e8c3d1f617950e2cdc6c2 100644 (file)
@@ -1003,7 +1003,7 @@ _public_ uint64_t sd_json_variant_unsigned(sd_json_variant *v) {
         if (!json_variant_is_regular(v))
                 goto mismatch;
         if (v->is_reference)
-                return sd_json_variant_integer(v->reference);
+                return sd_json_variant_unsigned(v->reference);
 
         switch (v->type) {