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-25 08:56:35 +03:00
parent 8e76197dff
commit 697f9fc986
6 changed files with 26 additions and 12 deletions

View File

@@ -1905,11 +1905,24 @@ static bool lua_reconstruct_ip6exthdr(lua_State *L, int idx, struct ip6_hdr *ip6
lua_getfield(L,-1, "data");
if (lua_type(L,-1)!=LUA_TSTRING) goto err;
if (!(p=(uint8_t*)lua_tolstring(L,-1,&l))) l=0;
if (l<6 || (l+2)>left || (type==IPPROTO_AH ? (l>=1024 || ((l+2) & 3)) : (l>=2048 || ((l+2) & 7)))) goto err;
memcpy(data+2,p,l);
l+=2;
if (l<6 || (l+2)>left) goto err;
if (type==IPPROTO_AH)
{
if (l>=1024 || ((l+2) & 3)) goto err;
memcpy(data+2,p,l);
l+=2;
data[1] = (l>>2)-2;
}
else
{
if (l>=2048 || ((l+2) & 7)) goto err;
memcpy(data+2,p,l);
l+=2;
data[1] = (l>>3)-1;
}
data[0] = next; // may be overwritten later
data[1] = (type==IPPROTO_AH) ? (l>>2)-2 : (l>>3)-1;
if (!preserve_next) *last_proto = type;
last_proto = data; // first byte of header holds type
left -= l; data += l; filled += l;