diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2003-01-09 02:52:00 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2003-01-09 02:52:00 +0000 |
commit | f3ba1b333f3d2c3a0007a91bf2ec133aae943748 (patch) | |
tree | 724e339d3234f60fc4ab6e269834dce6098aa696 | |
parent | a18c82e1257f2814468e764740843536e5db3a19 (diff) |
Don't write past the end of the address buffer. Found by Theo.
-rw-r--r-- | sbin/isakmpd/util.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 16f89d40d07..b90eb9d2345 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.28 2002/06/09 08:13:07 todd Exp $ */ +/* $OpenBSD: util.c,v 1.29 2003/01/09 02:51:59 ho Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -398,10 +398,12 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) return -1; for (i = 0, j = 0; i < 8; i++) - j += snprintf ((*address) + j, addrlen - j, "%02x%02x:", - ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[2 * i], - ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[2 * i + 1]); - (*address)[j - 1] = '\0'; + { + j += snprintf ((*address) + j, addrlen - j, "%02x%02x", + ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[2 * i], + ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[2 * i + 1]); + (*address)[j] = (++j < addrlen) ? ':' : '\0'; + } break; default: |