From c5437d43bd21284a561b1c3b1333f6235864f204 Mon Sep 17 00:00:00 2001 From: Hakan Olsson Date: Wed, 23 Jan 2002 17:10:10 +0000 Subject: less strcpy/strcat --- sbin/isakmpd/util.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index b469056f9b3..42b846b33a3 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.24 2002/01/19 20:12:02 angelos Exp $ */ +/* $OpenBSD: util.c,v 1.25 2002/01/23 17:10:09 ho Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -352,10 +352,9 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) if (zflag == 0) { - *address = malloc (strlen (buf) + 1); + *address = strdup (buf); if (!*address) return -1; - strcpy (*address, buf); } else switch (sa->sa_family) @@ -383,7 +382,7 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) } sprintf (*address + strlen (*address), "%03ld", val); if (bstart) - strcat (*address + strlen (*address), "."); + strlcat (*address, ".", addrlen); } break; @@ -405,7 +404,9 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) break; default: - strcpy (*address, ""); + *address = strdup (""); + if (!*address) + return -1; } return 0; -- cgit v1.2.3