From 99715dc6e2d3f9f801df0d0e983b0a1b428fc5ca Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 28 Jun 2018 12:23:29 +0100 Subject: [PATCH] Adding check for total length as well. --- srsepc/src/spgw/spgw.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index b785049c0..a759bf3bc 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -335,9 +335,11 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg) m_spgw_log->warning("IPv6 not supported yet.\n"); return; } - - //m_spgw_log->console("IP version: %d\n", version); - //m_spgw_log->console("Received packet to IP: %s\n", inet_ntoa(iph->daddr)); + if(iph->tot_len < 20) + { + m_spgw_log->warning("Invalid IP header length.\n"); + return; + } pthread_mutex_lock(&m_mutex); gtp_fteid_it = m_ip_to_teid.find(iph->daddr);