Dainis Jonitis <joni...@gmail.com> [2020-01-10 16:41:04]: Hi,
next time please make sure, that your From: match the Signed-off-by: -- I've fixed it this time. > libjson-c json_type_int values are stored as int64_t. Use > json_object_get_int64() instead of json_object_get_int() > to avoid clamping to INT32_MAX. > > Signed-off-by: Dainis Jonitis <dainis.joni...@ubnt.com> > --- > blobmsg_json.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/blobmsg_json.c b/blobmsg_json.c > index 1859211..394861a 100644 > --- a/blobmsg_json.c > +++ b/blobmsg_json.c > @@ -66,9 +66,15 @@ bool blobmsg_add_json_element(struct blob_buf *b, const > char *name, json_object > case json_type_boolean: > blobmsg_add_u8(b, name, json_object_get_boolean(obj)); > break; > - case json_type_int: > - blobmsg_add_u32(b, name, json_object_get_int(obj)); > + case json_type_int: { > + int64_t i64 = json_object_get_int64(obj); > + if (i64 >= INT32_MIN && i64 <= INT32_MAX) { This INT32_MAX should be UINT32_MAX, otherwise you're going to cast valid u32 values as u64, right? If you agree, I can do this small fix myself directly in my tree, to spare you from sending v2. -- ynezz _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel