Use os_strlcpy instead of os_strncpy when copying ifname
In theory, the ifname could be IFNAMSIZ characters long and there would not be room for null termination.
This commit is contained in:
parent
53c256a476
commit
a3bfd14de1
1 changed files with 2 additions and 2 deletions
|
@ -859,7 +859,7 @@ static int get_netif_info(const char *net_if, unsigned *ip_addr,
|
|||
if (sock < 0)
|
||||
goto fail;
|
||||
|
||||
os_strncpy(req.ifr_name, net_if, sizeof(req.ifr_name));
|
||||
os_strlcpy(req.ifr_name, net_if, sizeof(req.ifr_name));
|
||||
if (ioctl(sock, SIOCGIFADDR, &req) < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS UPnP: SIOCGIFADDR failed: %d (%s)",
|
||||
errno, strerror(errno));
|
||||
|
@ -870,7 +870,7 @@ static int get_netif_info(const char *net_if, unsigned *ip_addr,
|
|||
in_addr.s_addr = *ip_addr;
|
||||
os_snprintf(*ip_addr_text, 16, "%s", inet_ntoa(in_addr));
|
||||
|
||||
os_strncpy(req.ifr_name, net_if, sizeof(req.ifr_name));
|
||||
os_strlcpy(req.ifr_name, net_if, sizeof(req.ifr_name));
|
||||
if (ioctl(sock, SIOCGIFHWADDR, &req) < 0) {
|
||||
wpa_printf(MSG_ERROR, "WPS UPnP: SIOCGIFHWADDR failed: "
|
||||
"%d (%s)", errno, strerror(errno));
|
||||
|
|
Loading…
Reference in a new issue