Skip to contentSkip to conversation

lib: do not truncate 64 bit size in json

PATCH New Stephen Hemminger 1 participant 1 message Nov 8

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 lib: do not truncate 64 bit size in json

print_color_size() takes a 64 bit size but it gets truncated when printing json.

Reported-by Anthropic OSS scanner (ANT-2026-H0R4ZJSS)
---
 lib/json_print_math.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/json_print_math.c +2 -1
index 3e951cd9..85c29d6c 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 
 #include <stdarg.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <math.h>
 
@@ -33,7 +34,7 @@ int print_color_size(enum output_type type, enum color_attr color,
 	SPRINT_BUF(buf);
 
 	if (_IS_JSON_CONTEXT(type))
-		return print_color_uint(type, color, key, "%u", sz);
+		return print_color_u64(type, color, key, "%"PRIu64, sz);
 
 	sprint_size(sz, buf);
 	return print_color_string(type, color, key, fmt, buf);
Signature · 1 line
2.53.0