1
0
mirror of https://code.semirocket.science/wrapsix synced 2024-11-21 13:31:02 +02:00

Incorrect computing of packet size caused SIGSEGV

This commit is contained in:
Michal Zima 2012-04-27 14:43:09 +02:00
parent b28566bc64
commit 7012d02ab4

View File

@ -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;
}