Message ID | 1580734684-16319-1-git-send-email-alin.nastac@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [OpenWrt-Devel] ubus: lua binding does not allow a reply with 64 bit numbers | expand |
Hi, applied with slight changes in https://git.openwrt.org/?p=project/ubus.git;a=commitdiff;h=171469e3138cce191892e20b6fd35b52c9368064 - thanks! ~ Jo
diff --git a/lua/ubus.c b/lua/ubus.c index 86dcc50..aa01ac9 100644 --- a/lua/ubus.c +++ b/lua/ubus.c @@ -196,7 +196,11 @@ ubus_lua_format_blob(lua_State *L, struct blob_buf *b, bool table) case LUA_TINT: #endif case LUA_TNUMBER: - blobmsg_add_u32(b, key, (uint32_t)lua_tointeger(L, -1)); + if((uint64_t)lua_tonumber(L, -1) > INT_MAX) { + blobmsg_add_u64(b, key, (uint64_t)lua_tonumber(L, -1)); + } else { + blobmsg_add_u32(b, key, (uint32_t)lua_tointeger(L, -1)); + } break; case LUA_TSTRING:
Numbers originated from lua bindings get explicitly truncated to 32 bit. Signed-off-by: Alin Nastac <alin.nastac@gmail.com> --- lua/ubus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)