Skip to content

Commit

Permalink
Harden GTP classification when having padding
Browse files Browse the repository at this point in the history
  • Loading branch information
nhnghia committed Feb 26, 2024
1 parent 612147e commit 35f0ad7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mmt_tcpip/lib/protocols/proto_gtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int gtp_classify_next_proto(ipacket_t * ipacket, unsigned index) {
}

// not enough room
if( gtp_offset + offset >= ipacket->p_hdr->caplen )
if( gtp_offset + offset > ipacket->p_hdr->caplen )
return MMT_SKIP;

switch (gtp->message_type) {
Expand All @@ -143,9 +143,12 @@ int gtp_classify_next_proto(ipacket_t * ipacket, unsigned index) {
// ==> thus we need to trunk the length of proto_path
if( ipacket->session && ipacket->session->proto_path.len > index + 1 )
ipacket->session->proto_path.len = index + 1;
return MMT_DROP; //do not classify any further protocol after GTP

if( gtp_offset + offset >= ipacket->p_hdr->caplen )
return MMT_DROP; //do not classify any further protocol after GTP
}

//if we still have room after the GTP
return MMT_CONTINUE;
}

Expand Down

0 comments on commit 35f0ad7

Please sign in to comment.