From 05576df327e9acc3ae96757e8cee8a7ea6ae811d Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 31 Jan 2018 14:40:04 +0000 Subject: [PATCH] Fixed possibly non-null terminated string in spgw. --- srsepc/src/spgw/spgw.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 2458a065b..add16b2c4 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -175,7 +175,9 @@ spgw::init_sgi_if(spgw_args_t *args) memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TUN | IFF_NO_PI; - strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ); + strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1); + ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0'; + if(ioctl(m_sgi_if, TUNSETIFF, &ifr) < 0) { m_spgw_log->error("Failed to set TUN device name: %s\n", strerror(errno));