From 47953f4ef484158bd5acaac47ff337b94a9f86d2 Mon Sep 17 00:00:00 2001 From: faluco Date: Fri, 18 Sep 2020 14:10:15 +0200 Subject: [PATCH] - Prefer addrlen initialization for each call to recvfrom. --- srsepc/src/spgw/spgw.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index bef50fbe4..e2ec1749f 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -117,7 +117,6 @@ void spgw::run_thread() struct sockaddr_in src_addr_in; struct sockaddr_un src_addr_un; - socklen_t addrlen = sizeof(src_addr_in); struct iphdr* ip_pkt; int sgi = m_gtpu->get_sgi(); @@ -159,12 +158,14 @@ void spgw::run_thread() } if (FD_ISSET(s1u, &set)) { m_spgw_log->debug("Message received at SPGW: S1-U Message\n"); - s1u_msg->N_bytes = recvfrom(s1u, s1u_msg->msg, buf_len, 0, (struct sockaddr*)&src_addr_in, &addrlen); + socklen_t addrlen = sizeof(src_addr_in); + s1u_msg->N_bytes = recvfrom(s1u, s1u_msg->msg, buf_len, 0, (struct sockaddr*)&src_addr_in, &addrlen); m_gtpu->handle_s1u_pdu(s1u_msg); } if (FD_ISSET(s11, &set)) { m_spgw_log->debug("Message received at SPGW: S11 Message\n"); - s11_msg->N_bytes = recvfrom(s11, s11_msg->msg, buf_len, 0, (struct sockaddr*)&src_addr_un, &addrlen); + socklen_t addrlen = sizeof(src_addr_un); + s11_msg->N_bytes = recvfrom(s11, s11_msg->msg, buf_len, 0, (struct sockaddr*)&src_addr_un, &addrlen); m_gtpc->handle_s11_pdu(s11_msg); } } else {