diff -ru sbin/natd.orig/natd.c sbin/natd/natd.c --- sbin/natd.orig/natd.c 2004-08-26 19:04:32.000000000 -0300 +++ sbin/natd/natd.c 2004-10-25 22:00:14.000000000 -0200 @@ -422,12 +422,12 @@ break; if (len) { - strncat (parmBuf, " ", sizeof(parmBuf) - (len + 1)); + strlcat (parmBuf, " ", sizeof(parmBuf)); len += strlen(parmBuf + len); } ++arg; - strncat (parmBuf, argv[arg], sizeof(parmBuf) - (len + 1)); + strlcat (parmBuf, argv[arg], sizeof(parmBuf)); len += strlen(parmBuf + len); } @@ -580,7 +580,8 @@ } else if (errno == EACCES && logIpfwDenied) { - sprintf (msgBuf, "failed to write packet back"); + snprintf (msgBuf, sizeof(msgBuf), + "failed to write packet back"); Warn (msgBuf); } } @@ -636,13 +637,13 @@ char src[20]; char dst[20]; - strcpy (src, inet_ntoa (ip->ip_src)); - strcpy (dst, inet_ntoa (ip->ip_dst)); + strlcpy (src, inet_ntoa (ip->ip_src), sizeof(src)); + strlcpy (dst, inet_ntoa (ip->ip_dst), sizeof(dst)); switch (ip->ip_p) { case IPPROTO_TCP: tcphdr = (struct tcphdr*) ((char*) ip + (ip->ip_hl << 2)); - sprintf (buf, "[TCP] %s:%d -> %s:%d", + snprintf (buf, sizeof(buf), "[TCP] %s:%d -> %s:%d", src, ntohs (tcphdr->th_sport), dst, @@ -651,7 +652,7 @@ case IPPROTO_UDP: udphdr = (struct udphdr*) ((char*) ip + (ip->ip_hl << 2)); - sprintf (buf, "[UDP] %s:%d -> %s:%d", + snprintf (buf, sizeof(buf), "[UDP] %s:%d -> %s:%d", src, ntohs (udphdr->uh_sport), dst, @@ -660,7 +661,7 @@ case IPPROTO_ICMP: icmphdr = (struct icmp*) ((char*) ip + (ip->ip_hl << 2)); - sprintf (buf, "[ICMP] %s -> %s %u(%u)", + snprintf (buf, sizeof(buf), "[ICMP] %s -> %s %u(%u)", src, dst, icmphdr->icmp_type, @@ -668,7 +669,7 @@ break; default: - sprintf (buf, "[%d] %s -> %s ", ip->ip_p, src, dst); + snprintf (buf, sizeof(buf), "[%d] %s -> %s ", ip->ip_p, src, dst); break; } @@ -1351,7 +1352,7 @@ int i; struct alias_link *link = NULL; - strcpy (buf, parms); + strlcpy (buf, parms, sizeof(buf)); /* * Extract protocol. */ @@ -1482,7 +1483,7 @@ char* protoName; struct protoent *protoent; - strcpy (buf, parms); + strlcpy (buf, parms, sizeof(buf)); /* * Extract protocol. */ @@ -1536,7 +1537,7 @@ char* serverPool; struct alias_link *link; - strcpy (buf, parms); + strlcpy (buf, parms, sizeof(buf)); /* * Extract local address. */