diff --git a/docs/changes.txt b/docs/changes.txt index ff655f1..5944d8a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -194,3 +194,4 @@ v0.8.1 * winws2, blockcheck2: allow multiple instances in windows, linux, freebsd (not openbsd) * nfqws2: fix critical bug - wrong ipv6 dissection +* zapret-auto: fix standard_failure_detector http redirect regression diff --git a/lua/zapret-auto.lua b/lua/zapret-auto.lua index 3050d1d..1738ad0 100644 --- a/lua/zapret-auto.lua +++ b/lua/zapret-auto.lua @@ -181,13 +181,16 @@ function standard_failure_detector(desync, crec) end elseif not arg.no_http_redirect and desync.l7payload=="http_reply" and desync.track.hostname then local hdis = http_dissect_reply(desync.dis.payload) - if hdis and (hdis.code==302 or hdis.code==307) and hdis.headers.location and hdis.headers.location then - trigger = is_dpi_redirect(desync.track.hostname, hdis.headers.location.value) - if b_debug then - if trigger then - DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers.location.value.."'. looks like DPI redirect.") - else - DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers.location.value.."'. NOT a DPI redirect.") + if hdis and (hdis.code==302 or hdis.code==307) then + local idx_loc = array_field_search(hdis.headers, "header_low", "location") + if idx_loc then + trigger = is_dpi_redirect(desync.track.hostname, hdis.headers[idx_loc].value) + if b_debug then + if trigger then + DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers[idx_loc].value.."'. looks like DPI redirect.") + else + DLOG("standard_failure_detector: http redirect "..hdis.code.." to '"..hdis.headers[idx_loc].value.."'. NOT a DPI redirect.") + end end end end diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index 927d02a..7cca4a0 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -1558,6 +1558,9 @@ function writefile(filename, data) end local s,err = f:write(data) f:close() + if not s then + error("writefile: "..err) + end end -- DISSECTORS diff --git a/nfq2/lua.c b/nfq2/lua.c index 3f12aff..797f9a2 100644 --- a/nfq2/lua.c +++ b/nfq2/lua.c @@ -427,7 +427,7 @@ static int luacall_brandom(lua_State *L) { lua_check_argc(L,"brandom",1); lua_Integer len = luaL_checkinteger(L,1); - + if (len<0) luaL_error(L, "brandom: invalid arg"); uint8_t *p = malloc(len); if (!p) luaL_error(L, "out of memory"); fill_random_bytes(p,len); @@ -440,7 +440,7 @@ static int luacall_brandom_az(lua_State *L) { lua_check_argc(L,"brandom_az",1); lua_Integer len = luaL_checkinteger(L,1); - + if (len<0) luaL_error(L, "brandom_az: invalid arg"); uint8_t *p = malloc(len); if (!p) luaL_error(L, "out of memory"); fill_random_az(p,len); @@ -453,7 +453,7 @@ static int luacall_brandom_az09(lua_State *L) { lua_check_argc(L,"brandom_az09",1); lua_Integer len = luaL_checkinteger(L,1); - + if (len<0) luaL_error(L, "brandom_az09: invalid arg"); uint8_t *p = malloc(len); if (!p) luaL_error(L, "out of memory"); fill_random_az09(p,len); @@ -536,6 +536,7 @@ static int luacall_bcryptorandom(lua_State *L) LUA_STACK_GUARD_ENTER(L) lua_Integer len = luaL_checkinteger(L,1); + if (len<0) luaL_error(L, "bcryptorandom: invalid arg"); uint8_t *p = malloc(len); if (!p) luaL_error(L, "out of memory"); @@ -691,7 +692,8 @@ static int luacall_hkdf(lua_State *L) const uint8_t *ikm = lua_type(L,3) == LUA_TNIL ? NULL : (uint8_t*)luaL_checklstring(L,3,&ikm_len); size_t info_len=0; const uint8_t *info = lua_type(L,4) == LUA_TNIL ? NULL : (uint8_t*)luaL_checklstring(L,4,&info_len); - size_t okm_len = (size_t)luaL_checkinteger(L,5); + lua_Integer okm_len = luaL_checkinteger(L,5); + if (okm_len<0) luaL_error(L, "hkdf: invalid arg"); uint8_t *okm = malloc(okm_len); if (!okm) luaL_error(L, "out of memory"); @@ -2411,6 +2413,7 @@ static void lua_rawsend_extract_options(lua_State *L, int idx, int *repeats, uin { lua_getfield(L,idx,"repeats"); *repeats=(int)lua_tointeger(L,-1); + if (*repeats<0) luaL_error(L, "rawsend: negative repeats"); if (!*repeats) *repeats=1; lua_pop(L,1); }