From 40c4c9b2ba424b6d434a29cb2f596450eb6da288 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 9 Jan 2020 16:45:57 +0900 Subject: [PATCH] Fix potential non-null-terminated string bug --- src/UDPConnection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index 54cf423..fd021b3 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -2907,6 +2907,7 @@ UDPC_IPV6_ADDR_TYPE UDPC_strtoa_link(const char *addrStr, uint32_t *linkId_out) else { struct ifreq req{{0}, 0, 0}; std::strncpy(req.ifr_name, linkName, IFNAMSIZ); + req.ifr_name[IFNAMSIZ - 1] = 0; int socketHandle = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); if(ioctl(socketHandle, SIOCGIFINDEX, &req) < 0) { UDPC_CLEANUPSOCKET(socketHandle);