mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
AI fixes
This commit is contained in:
@@ -19,10 +19,10 @@ struct icmp46
|
|||||||
uint16_t icmp_cksum;
|
uint16_t icmp_cksum;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32_t icmp_data32;
|
uint32_t data32;
|
||||||
uint16_t icmp_data16[2];
|
uint16_t data16[2];
|
||||||
uint8_t icmp_data8[4];
|
uint8_t data8[4];
|
||||||
};
|
} data;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16_t csum_tcpudp_magic(uint32_t saddr, uint32_t daddr, size_t len, uint8_t proto, uint16_t sum);
|
uint16_t csum_tcpudp_magic(uint32_t saddr, uint32_t daddr, size_t len, uint8_t proto, uint16_t sum);
|
||||||
|
|||||||
@@ -358,9 +358,9 @@ void str_icmphdr(char *s, size_t s_len, bool v6, const struct icmp46 *icmp)
|
|||||||
char stype[32];
|
char stype[32];
|
||||||
str_icmp_type_name(stype,sizeof(stype),v6,icmp->icmp_type);
|
str_icmp_type_name(stype,sizeof(stype),v6,icmp->icmp_type);
|
||||||
if (icmp->icmp_type==ICMP_ECHO || icmp->icmp_type==ICMP_ECHOREPLY || icmp->icmp_type==ICMP6_ECHO_REQUEST || icmp->icmp_type==ICMP6_ECHO_REPLY)
|
if (icmp->icmp_type==ICMP_ECHO || icmp->icmp_type==ICMP_ECHOREPLY || icmp->icmp_type==ICMP6_ECHO_REQUEST || icmp->icmp_type==ICMP6_ECHO_REPLY)
|
||||||
snprintf(s,s_len,"icmp_type=%s icmp_code=%u id=0x%04X seq=%u",stype,icmp->icmp_code,ntohs(icmp->icmp_data16[0]),ntohs(icmp->icmp_data16[1]));
|
snprintf(s,s_len,"icmp_type=%s icmp_code=%u id=0x%04X seq=%u",stype,icmp->icmp_code,ntohs(icmp->data.data16[0]),ntohs(icmp->data.data16[1]));
|
||||||
else
|
else
|
||||||
snprintf(s,s_len,"icmp_type=%s icmp_code=%u data=0x%08X",stype,icmp->icmp_code,ntohl(icmp->icmp_data32));
|
snprintf(s,s_len,"icmp_type=%s icmp_code=%u data=0x%08X",stype,icmp->icmp_code,ntohl(icmp->data.data32));
|
||||||
}
|
}
|
||||||
void print_icmphdr(const struct icmp46 *icmp, bool v6)
|
void print_icmphdr(const struct icmp46 *icmp, bool v6)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ void expand_bits(void *target, const void *source, unsigned int source_bitlen, u
|
|||||||
unsigned int bitlen = target_bitlen<source_bitlen ? target_bitlen : source_bitlen;
|
unsigned int bitlen = target_bitlen<source_bitlen ? target_bitlen : source_bitlen;
|
||||||
unsigned int bytelen = bitlen>>3;
|
unsigned int bytelen = bitlen>>3;
|
||||||
|
|
||||||
if ((target_bytelen-bytelen)>=1) memset(target+bytelen,0,target_bytelen-bytelen);
|
if ((target_bytelen-bytelen)>=1) memset((uint8_t*)target+bytelen,0,target_bytelen-bytelen);
|
||||||
memcpy(target,source,bytelen);
|
memcpy(target,source,bytelen);
|
||||||
if ((bitlen &= 7)) ((uint8_t*)target)[bytelen] = ((uint8_t*)source)[bytelen] & (~((1 << (8-bitlen)) - 1));
|
if ((bitlen &= 7)) ((uint8_t*)target)[bytelen] = ((uint8_t*)source)[bytelen] & (~((1 << (8-bitlen)) - 1));
|
||||||
}
|
}
|
||||||
@@ -504,6 +504,14 @@ int getentropy(void *buf, size_t len)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t read_intr(int fd, void *buf, size_t count)
|
||||||
|
{
|
||||||
|
ssize_t rd;
|
||||||
|
while ((rd=read(fd,buf,count))<0 && errno==EINTR);
|
||||||
|
return rd;
|
||||||
|
}
|
||||||
|
|
||||||
bool fill_crypto_random_bytes(uint8_t *p,size_t sz)
|
bool fill_crypto_random_bytes(uint8_t *p,size_t sz)
|
||||||
{
|
{
|
||||||
ssize_t rd;
|
ssize_t rd;
|
||||||
@@ -526,7 +534,7 @@ bool fill_crypto_random_bytes(uint8_t *p,size_t sz)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((rd=read(fd,p,sz))>0)
|
if ((rd=read_intr(fd,p,sz))>0)
|
||||||
{
|
{
|
||||||
p+=rd; sz-=rd;
|
p+=rd; sz-=rd;
|
||||||
}
|
}
|
||||||
@@ -537,7 +545,7 @@ bool fill_crypto_random_bytes(uint8_t *p,size_t sz)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((rd=read(fd,p,sz))>0)
|
if ((rd=read_intr(fd,p,sz))>0)
|
||||||
{
|
{
|
||||||
p+=rd; sz-=rd;
|
p+=rd; sz-=rd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ const char *strncasestr(const char *s,const char *find, size_t slen);
|
|||||||
// [a-zA-z][a-zA-Z0-9]*
|
// [a-zA-z][a-zA-Z0-9]*
|
||||||
bool is_identifier(const char *p);
|
bool is_identifier(const char *p);
|
||||||
|
|
||||||
|
ssize_t read_intr(int fd, void *buf, size_t count);
|
||||||
|
|
||||||
bool load_file(const char *filename, off_t offset, void *buffer, size_t *buffer_size);
|
bool load_file(const char *filename, off_t offset, void *buffer, size_t *buffer_size);
|
||||||
bool save_file(const char *filename, const void *buffer, size_t buffer_size);
|
bool save_file(const char *filename, const void *buffer, size_t buffer_size);
|
||||||
bool append_to_list_file(const char *filename, const char *s);
|
bool append_to_list_file(const char *filename, const char *s);
|
||||||
|
|||||||
@@ -1422,7 +1422,7 @@ void lua_push_icmphdr(lua_State *L, const struct icmp46 *icmp, size_t len)
|
|||||||
lua_pushf_int(L,"icmp_type",icmp->icmp_type);
|
lua_pushf_int(L,"icmp_type",icmp->icmp_type);
|
||||||
lua_pushf_int(L,"icmp_code",icmp->icmp_code);
|
lua_pushf_int(L,"icmp_code",icmp->icmp_code);
|
||||||
lua_pushf_int(L,"icmp_cksum",ntohs(icmp->icmp_cksum));
|
lua_pushf_int(L,"icmp_cksum",ntohs(icmp->icmp_cksum));
|
||||||
lua_pushf_lint(L,"icmp_data",ntohl(icmp->icmp_data32));
|
lua_pushf_lint(L,"icmp_data",ntohl(icmp->data.data32));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@@ -2318,7 +2318,7 @@ bool lua_reconstruct_icmphdr(lua_State *L, int idx, struct icmp46 *icmp)
|
|||||||
|
|
||||||
lua_getfield(L,idx,"icmp_data");
|
lua_getfield(L,idx,"icmp_data");
|
||||||
if (lua_type(L,-1)!=LUA_TNUMBER) goto err;
|
if (lua_type(L,-1)!=LUA_TNUMBER) goto err;
|
||||||
icmp->icmp_data32 = htonl((uint32_t)lua_tolint(L,-1));
|
icmp->data.data32 = htonl((uint32_t)lua_tolint(L,-1));
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
lua_getfield(L,idx,"icmp_cksum");
|
lua_getfield(L,idx,"icmp_cksum");
|
||||||
@@ -3511,7 +3511,7 @@ static void *z_alloc(voidpf opaque, uInt items, uInt size)
|
|||||||
}
|
}
|
||||||
static void z_free(voidpf opaque, voidpf address)
|
static void z_free(voidpf opaque, voidpf address)
|
||||||
{
|
{
|
||||||
return free(address);
|
free(address);
|
||||||
}
|
}
|
||||||
static int luacall_gzip_init(lua_State *L)
|
static int luacall_gzip_init(lua_State *L)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user