}
else
{
- sprintf (buffer, "%ld", pair->lvalue);
+ sprintf (buffer, "%d", pair->lvalue);
strncpy(value, buffer, (size_t) lv);
}
break;
if ((h = strtok (buffer, " \t\n")) == NULL) /* first hostname */
continue;
- memset (hostnm, '\0', AUTH_ID_LEN);
- len = strlen (h);
- if (len > AUTH_ID_LEN)
- {
- len = AUTH_ID_LEN;
- }
- strncpy (hostnm, h, (size_t) len);
- hostnm[AUTH_ID_LEN] = '\0';
+ memset (hostnm, '\0', AUTH_ID_LEN + 1);
+ strlcpy (hostnm, h, AUTH_ID_LEN + 1);
if ((s = strtok (NULL, " \t\n")) == NULL) /* and secret field */
continue;
- memset (secret, '\0', MAX_SECRET_LENGTH);
- len = strlen (s);
- if (len > MAX_SECRET_LENGTH)
- {
- len = MAX_SECRET_LENGTH;
- }
- strncpy (secret, s, (size_t) len);
- secret[MAX_SECRET_LENGTH] = '\0';
+ memset (secret, '\0', MAX_SECRET_LENGTH + 1);
+ strlcpy (secret, s, MAX_SECRET_LENGTH + 1);
if (!strchr (hostnm, '/')) /* If single name form */
{
static void
PPPOEDeviceOptions(void)
{
- char buf[256];
- snprintf(buf, 256, _PATH_ETHOPT "%s", devnam);
+ char buf[MAXPATHLEN];
+
+ strlcpy(buf, _PATH_ETHOPT, MAXPATHLEN);
+ strlcat(buf, devnam, MAXPATHLEN);
if (!options_from_file(buf, 0, 0, 1))
exit(EXIT_OPTION_ERROR);
memset((void *)&ll, 0, sizeof(ll));
(void)time(&tnow);
ll.ll_time = tnow;
- (void)strncpy(ll.ll_line, ttyName, sizeof(ll.ll_line));
- (void)strncpy(ll.ll_host, ifname, sizeof(ll.ll_host));
+ strlcpy(ll.ll_line, ttyName, sizeof(ll.ll_line));
+ strlcpy(ll.ll_host, ifname, sizeof(ll.ll_host));
(void)write(fd, (char *)&ll, sizeof(ll));
(void)close(fd);
}
char t[MAXIFNAMELEN];
memset(&ifr, 0, sizeof(struct ifreq));
slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
- strncpy(ifr.ifr_name, t, IF_NAMESIZE);
- strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
+ strlcpy(ifr.ifr_name, t, IF_NAMESIZE);
+ strlcpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
if (x < 0)
error("Couldn't rename interface %s to %s: %m", t, req_ifname);