If the Lua number exceeds the maximum value representable by an
unsigned 32bit integer, store it in an unsigned 64bit integer
field instead.
Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
[align code style, reword commit message]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
case LUA_TINT:
#endif
case LUA_TNUMBER:
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));