Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00
This commit is contained in:
bol-van
2026-02-11 11:02:50 +03:00
parent 827ab7cdcc
commit 8b2bff4187
4 changed files with 18 additions and 10 deletions

View File

@@ -477,7 +477,7 @@ function per_instance_condition(ctx, desync)
if not instance then break end if not instance then break end
if instance.arg.cond then if instance.arg.cond then
if type(_G[instance.arg.cond])~="function" then if type(_G[instance.arg.cond])~="function" then
error(name..": invalid 'iff' function '"..instance.arg.cond.."'") error("per_instance_condition: invalid 'iff' function '"..instance.arg.cond.."'")
end end
if logical_xor(_G[instance.arg.cond](desync), instance.arg.cond_neg) then if logical_xor(_G[instance.arg.cond](desync), instance.arg.cond_neg) then
verdict = plan_instance_execute(desync, verdict, instance) verdict = plan_instance_execute(desync, verdict, instance)

View File

@@ -90,10 +90,9 @@ function test_hkdf()
local ikm = brandom(math.random(5,10)) local ikm = brandom(math.random(5,10))
for ninfo=1,nblob do for ninfo=1,nblob do
local info = brandom(math.random(5,10)) local info = brandom(math.random(5,10))
local okm_prev
for k,sha in pairs({"sha256","sha224"}) do for k,sha in pairs({"sha256","sha224"}) do
for k,okml in pairs({8, 16, 50}) do
local okm_prev local okm_prev
for k,okml in pairs({8, 16, 50}) do
local okm local okm
print("* hkdf "..sha) print("* hkdf "..sha)
print("salt: "..string2hex(salt)) print("salt: "..string2hex(salt))
@@ -107,7 +106,6 @@ function test_hkdf()
print("duplicate okm !") print("duplicate okm !")
end end
okms[okm] = true okms[okm] = true
test_assert(not okm_prev or okm_prev==string.sub(okm, 1, #okm_prev)) test_assert(not okm_prev or okm_prev==string.sub(okm, 1, #okm_prev))
okm_prev = okm okm_prev = okm
end end

View File

@@ -2569,12 +2569,13 @@ bool lua_reconstruct_dissect(lua_State *L, int idx, uint8_t *buf, size_t *len, b
DLOG_ERR("ipv4 frag : invalid ip_len\n"); DLOG_ERR("ipv4 frag : invalid ip_len\n");
goto err; goto err;
} }
if (frag_start>l) size_t frag_len = iplen-l3;
if ((frag_start+frag_len)>l)
{ {
DLOG_ERR("ipv4 frag : fragment offset is outside of the packet\n"); DLOG_ERR("ipv4 frag : fragment end is outside of the packet\n");
goto err; goto err;
} }
if (off) memmove(buf+l3,buf+l3+off,iplen-l3); if (off) memmove(buf+l3,buf+frag_start,frag_len);
l = iplen; // shrink packet to iplen l = iplen; // shrink packet to iplen
} }
else else

View File

@@ -350,10 +350,19 @@ void daemonize(void)
DLOG_PERROR("setsid"); DLOG_PERROR("setsid");
exit(21); exit(21);
} }
if (close(STDIN_FILENO)<0 || close(STDOUT_FILENO)<0 || close(STDERR_FILENO)<0) if (close(STDIN_FILENO)<0 && errno!=EBADF)
{ {
// will work only if debug not to console DLOG_PERROR("close(stdin)");
DLOG_PERROR("close"); exit(22);
}
if (close(STDOUT_FILENO)<0 && errno!=EBADF)
{
DLOG_PERROR("close(stdout)");
exit(22);
}
if (close(STDERR_FILENO)<0 && errno!=EBADF)
{
DLOG_PERROR("close(stderr)");
exit(22); exit(22);
} }
/* redirect fd's 0,1,2 to /dev/null */ /* redirect fd's 0,1,2 to /dev/null */