mirror of
https://code.semirocket.science/wrapsix
synced 2024-11-08 15:21:00 +02:00
Incorrect computing of packet size caused SIGSEGV
This commit is contained in:
parent
b28566bc64
commit
7012d02ab4
@ -219,7 +219,6 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload)
|
||||
unsigned short orig_checksum;
|
||||
struct s_ipv4 *ip4;
|
||||
unsigned char *packet;
|
||||
unsigned int packet_size;
|
||||
|
||||
/* parse TCP header */
|
||||
tcp = (struct s_tcp *) payload;
|
||||
@ -249,8 +248,8 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload)
|
||||
}
|
||||
|
||||
/* allocate memory for translated packet */
|
||||
packet_size = sizeof(struct s_ipv4) + ip6->len;
|
||||
if ((packet = (unsigned char *) malloc(packet_size)) == NULL) {
|
||||
if ((packet = (unsigned char *) malloc(sizeof(struct s_ipv4) +
|
||||
htons(ip6->len))) == NULL) {
|
||||
fprintf(stderr, "[Error] Lack of free memory\n");
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user