diff options
| author | 2004-09-16 21:27:44 +0000 | |
|---|---|---|
| committer | 2004-09-16 21:27:44 +0000 | |
| commit | a53ae031b92fde5217c78b445604f0fcee074de9 (patch) | |
| tree | 11a3c50eb39dcd80e0c49980345ca8a01c178b9c | |
| parent | mips64 is ELFSIZE 64. ok deraadt@ (diff) | |
| download | wireguard-openbsd-a53ae031b92fde5217c78b445604f0fcee074de9.tar.xz wireguard-openbsd-a53ae031b92fde5217c78b445604f0fcee074de9.zip | |
Use inet_ntop() instead of inet_ntoa() in piaddr. This solves a problem
where inet_ntoa() was called twice per log message -- once here and once
directly. This is a workaround acctually no static buffer should be used.
OK deraadt@
| -rw-r--r-- | usr.sbin/dhcpd/inet.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/dhcpd/inet.c b/usr.sbin/dhcpd/inet.c index 788abcdfc83..6255b37184f 100644 --- a/usr.sbin/dhcpd/inet.c +++ b/usr.sbin/dhcpd/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.4 2004/05/04 20:28:40 deraadt Exp $ */ +/* $OpenBSD: inet.c,v 1.5 2004/09/16 21:27:44 claudio Exp $ */ /* * Subroutines to manipulate internet addresses in a safely portable @@ -141,18 +141,13 @@ char * piaddr(struct iaddr addr) { static char pbuf[32]; - struct in_addr a; - char *s; - - memcpy(&a, &(addr.iabuf), sizeof(struct in_addr)); + const char *s; if (addr.len == 0) strlcpy(pbuf, "<null address>", sizeof(pbuf)); else { - s = inet_ntoa(a); - if (s != NULL) - strlcpy(pbuf, s, sizeof(pbuf)); - else + s = inet_ntop(AF_INET, &addr.iabuf, pbuf, sizeof pbuf); + if (s == NULL) strlcpy(pbuf, "<invalid address>", sizeof(pbuf)); } return (pbuf); |
