diff options
author | 2001-06-29 04:52:22 +0000 | |
---|---|---|
committer | 2001-06-29 04:52:22 +0000 | |
commit | 1f1358be41588d875f64b8393b327e22a7a0e629 (patch) | |
tree | 862aff1e1593491d81645e8dd3f0cadd73c60286 | |
parent | cleanup, including removing the size rule which nobody (diff) | |
download | wireguard-openbsd-1f1358be41588d875f64b8393b327e22a7a0e629.tar.xz wireguard-openbsd-1f1358be41588d875f64b8393b327e22a7a0e629.zip |
Style fix as per niklas@'s suggestion.
-rw-r--r-- | sbin/isakmpd/util.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 3e45942d551..33b6c17a0b0 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.15 2001/06/29 04:12:01 ho Exp $ */ +/* $OpenBSD: util.c,v 1.16 2001/06/29 04:52:22 ho Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -278,7 +278,7 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) { char buf[NI_MAXHOST]; char *token, *bstart, *p; - int c_pre = 0, c_post = 0; + int addrlen, c_pre = 0, c_post = 0; #ifdef HAVE_GETNAMEINFO if (getnameinfo (sa, sa->sa_len, buf, sizeof buf, 0, 0, @@ -309,9 +309,11 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) switch (sa->sa_family) { case AF_INET: - *address = malloc (16); - if (*address == NULL) + addrlen = sizeof "000.000.000.000"; + *address = malloc (addrlen); + if (!*address) return -1; + buf[addrlen] = '\0'; /* Terminate */ bstart = buf; **address = '\0'; while ((token = strsep (&bstart, ".")) != NULL) { @@ -327,17 +329,20 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) } break; case AF_INET6: - *address = malloc (40); - if (!address) + addrlen = sizeof "0000:0000:0000:0000:0000:0000:0000:0000"; + *address = malloc (addrlen); + if (!*address) return -1; bstart = buf; **address = '\0'; - buf[40] = '\0'; /* Make sure buf is terminated. */ + buf[addrlen] = '\0'; /* Terminate */ while ((token = strsep (&bstart, ":")) != NULL) { if (strlen (token) == 0) { - /* Encountered a '::'. Fill out the string. */ - /* XXX Isn't there a library function for this somewhere? */ + /* + * Encountered a '::'. Fill out the string. + * XXX Isn't there a library function for this somewhere? + */ for (p = buf; p < token - 1; p++) if (*p == 0) c_pre++; |