From f30316720630200ced172b1999e1a3282d7e9064 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 1 May 2019 12:56:01 +0100 Subject: [PATCH] Fix GTP-C socket initialization to remove compiler warnings. --- srsepc/src/mme/mme_gtpc.cc | 4 ++-- srsepc/src/spgw/gtpc.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 934567996..3c8a07763 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -100,7 +100,7 @@ bool mme_gtpc::init_s11() // Set MME Address memset(&m_mme_addr, 0, sizeof(struct sockaddr_un)); m_mme_addr.sun_family = AF_UNIX; - strncpy(m_mme_addr.sun_path, mme_addr_name, strlen(mme_addr_name)); + snprintf(m_mme_addr.sun_path, sizeof(m_mme_addr.sun_path), "%s", mme_addr_name); m_mme_addr.sun_path[0] = '\0'; // Bind socket to address @@ -112,7 +112,7 @@ bool mme_gtpc::init_s11() // Set SPGW Address for later use memset(&m_spgw_addr, 0, sizeof(struct sockaddr_un)); m_spgw_addr.sun_family = AF_UNIX; - strncpy(m_spgw_addr.sun_path, spgw_addr_name, strlen(spgw_addr_name)); + snprintf(m_spgw_addr.sun_path, sizeof(m_spgw_addr.sun_path), "%s", spgw_addr_name); m_spgw_addr.sun_path[0] = '\0'; m_mme_gtpc_log->info("MME S11 Initialized\n"); diff --git a/srsepc/src/spgw/gtpc.cc b/srsepc/src/spgw/gtpc.cc index 89345960e..7598a8588 100644 --- a/srsepc/src/spgw/gtpc.cc +++ b/srsepc/src/spgw/gtpc.cc @@ -118,13 +118,13 @@ srslte::error_t spgw::gtpc::init_s11(spgw_args_t* args) // Set MME Address memset(&m_mme_addr, 0, sizeof(struct sockaddr_un)); m_mme_addr.sun_family = AF_UNIX; - strncpy(m_mme_addr.sun_path, mme_addr_name, strlen(mme_addr_name)); + snprintf(m_mme_addr.sun_path, sizeof(m_mme_addr.sun_path), "%s", mme_addr_name); m_mme_addr.sun_path[0] = '\0'; // Set SPGW Address memset(&m_spgw_addr, 0, sizeof(struct sockaddr_un)); m_spgw_addr.sun_family = AF_UNIX; - strncpy(m_spgw_addr.sun_path, spgw_addr_name, strlen(spgw_addr_name)); + snprintf(m_spgw_addr.sun_path, sizeof(m_spgw_addr.sun_path), "%s", spgw_addr_name); m_spgw_addr.sun_path[0] = '\0'; // Bind socket to address