Replace non-essential strncpy() calls.

This commit is contained in:
Todd C. Miller
2019-07-30 11:37:26 -06:00
parent aa73c86a5b
commit aa200cda6a
2 changed files with 6 additions and 4 deletions

View File

@@ -90,8 +90,10 @@ group_plugin_load(char *plugin_info)
savedch = *args;
*args = '\0';
}
strncpy(path, plugin_info, sizeof(path) - 1);
path[sizeof(path) - 1] = '\0';
if (strlcpy(path, plugin_info, sizeof(path)) >= sizeof(path)) {
fprintf(stderr, "path too long: %s\n", plugin_info);
return -1;
}
if (args != NULL)
*args++ = savedch;

View File

@@ -309,7 +309,7 @@ get_net_ifs(char **addrinfo)
#ifdef SIOCGIFFLAGS
memset(ifr_tmp, 0, sizeof(*ifr_tmp));
strncpy(ifr_tmp->ifr_name, ifr->ifr_name, sizeof(ifr_tmp->ifr_name) - 1);
memcpy(ifr_tmp->ifr_name, ifr->ifr_name, sizeof(ifr_tmp->ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, (caddr_t) ifr_tmp) < 0)
#endif
memcpy(ifr_tmp, ifr, sizeof(*ifr_tmp));
@@ -321,7 +321,7 @@ get_net_ifs(char **addrinfo)
/* Get the netmask. */
memset(ifr_tmp, 0, sizeof(*ifr_tmp));
strncpy(ifr_tmp->ifr_name, ifr->ifr_name, sizeof(ifr_tmp->ifr_name) - 1);
memcpy(ifr_tmp->ifr_name, ifr->ifr_name, sizeof(ifr_tmp->ifr_name));
sin = (struct sockaddr_in *) &ifr_tmp->ifr_addr;
#ifdef _ISC
STRSET(SIOCGIFNETMASK, (caddr_t) ifr_tmp, sizeof(*ifr_tmp));