Numbers originated from lua bindings get explicitly truncated to 32 bit.

Signed-off-by: Alin Nastac <alin.nas...@gmail.com>
---
 lua/ubus.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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:
-- 
2.7.4


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to