Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate ip length before using tcp header. #319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mtcp/src/tcp_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,10 @@ int
ProcessTCPPacket(mtcp_manager_t mtcp,
uint32_t cur_ts, const int ifidx, const struct iphdr *iph, int ip_len)
{
if (ip_len < (iph->ihl << 2) + sizeof(struct tcphdr)) {
TRACE_DBG("Invalid IP header length\n");
return ERROR;
}
struct tcphdr* tcph = (struct tcphdr *) ((u_char *)iph + (iph->ihl << 2));
uint8_t *payload = (uint8_t *)tcph + (tcph->doff << 2);
int payloadlen = ip_len - (payload - (u_char *)iph);
Expand Down