Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00

nfqws2: bitset/bitget check negative from-to

This commit is contained in:
bol-van
2026-01-14 17:39:15 +03:00
parent 236550918b
commit 10201f1abf

View File

@@ -174,7 +174,7 @@ static int luacall_bitget(lua_State *L)
uint64_t what = (uint64_t)iwhat;
lua_Integer from = luaL_checkinteger(L,2);
lua_Integer to = luaL_checkinteger(L,3);
if (from>to || from>47 || to>47)
if (from<0 || to<0 || from>to || from>47 || to>47)
luaL_error(L, "bit range invalid");
what = (what >> from) & ~((lua_Integer)-1 << (to-from+1));
@@ -194,7 +194,7 @@ static int luacall_bitset(lua_State *L)
int64_t iset = (int64_t)luaL_checklint(L,4);
if (iset>0xFFFFFFFFFFFF || iset<-(int64_t)0xFFFFFFFFFFFF) luaL_error(L, "out of range");
uint64_t set = (uint64_t)iset;
if (from>to || from>47 || to>47)
if (from<0 || to<0 || from>to || from>47 || to>47)
luaL_error(L, "bit range invalid");
uint64_t mask = ~((uint64_t)-1 << (to-from+1));