openbsd-ports/net/cidr/patches/patch-cidr_c
david d22c72f730 fix incorrect uses of strncpy (strings were not being null terminated)
and replace with strlcpy; found with malloc.conf
ok millert@
2004-06-16 18:07:53 +00:00

30 lines
782 B
Plaintext

$OpenBSD: patch-cidr_c,v 1.1 2004/06/16 18:07:53 david Exp $
--- cidr.c.orig 2000-06-20 18:10:55.000000000 -0500
+++ cidr.c 2004-06-16 12:46:55.000000000 -0500
@@ -154,14 +154,14 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- strncpy(ip[2],argv[1],18);
+ strlcpy(ip[2],argv[1],19);
holdaddress=strtok(ip[2],sep);
if(holdaddress==NULL)
invalid(1);
- strncpy(ip[0],holdaddress,strlen(holdaddress));
+ strlcpy(ip[0],holdaddress,strlen(holdaddress)+1);
if(ip[0]==NULL)
invalid(1);
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
if(holdprefix==NULL)
invalid(1);
- strncpy(ip[1],holdprefix,strlen(holdprefix));
+ strlcpy(ip[1],holdprefix,strlen(holdprefix)+1);
if(ip[1]==NULL)
invalid(1);