Fix potential non-null-terminated string bug
This commit is contained in:
parent
4d68715efb
commit
40c4c9b2ba
1 changed files with 1 additions and 0 deletions
|
@ -2907,6 +2907,7 @@ UDPC_IPV6_ADDR_TYPE UDPC_strtoa_link(const char *addrStr, uint32_t *linkId_out)
|
||||||
else {
|
else {
|
||||||
struct ifreq req{{0}, 0, 0};
|
struct ifreq req{{0}, 0, 0};
|
||||||
std::strncpy(req.ifr_name, linkName, IFNAMSIZ);
|
std::strncpy(req.ifr_name, linkName, IFNAMSIZ);
|
||||||
|
req.ifr_name[IFNAMSIZ - 1] = 0;
|
||||||
int socketHandle = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
int socketHandle = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if(ioctl(socketHandle, SIOCGIFINDEX, &req) < 0) {
|
if(ioctl(socketHandle, SIOCGIFINDEX, &req) < 0) {
|
||||||
UDPC_CLEANUPSOCKET(socketHandle);
|
UDPC_CLEANUPSOCKET(socketHandle);
|
||||||
|
|
Loading…
Reference in a new issue