summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortedu <>2014-05-17 18:16:14 +0000
committertedu <>2014-05-17 18:16:14 +0000
commita954fb1da2e59cf7b4af01a300533844d594f63c (patch)
tree3568993d7214fb09929d95105a2eaf99bbbcd4ca
parenta0400d85abf0e363ba5b1fc257be8af941da409b (diff)
downloadopenbsd-a954fb1da2e59cf7b4af01a300533844d594f63c.tar.gz
openbsd-a954fb1da2e59cf7b4af01a300533844d594f63c.tar.bz2
openbsd-a954fb1da2e59cf7b4af01a300533844d594f63c.zip
correctly match size and buffer. from enh at google
-rw-r--r--src/lib/libc/net/inet_ntop.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/net/inet_ntop.c b/src/lib/libc/net/inet_ntop.c
index 359acd8cda..f991a071ba 100644
--- a/src/lib/libc/net/inet_ntop.c
+++ b/src/lib/libc/net/inet_ntop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: inet_ntop.c,v 1.9 2014/02/05 14:20:43 millert Exp $ */ 1/* $OpenBSD: inet_ntop.c,v 1.10 2014/05/17 18:16:14 tedu Exp $ */
2 2
3/* Copyright (c) 1996 by Internet Software Consortium. 3/* Copyright (c) 1996 by Internet Software Consortium.
4 * 4 *
@@ -71,11 +71,11 @@ inet_ntop(int af, const void *src, char *dst, socklen_t size)
71static const char * 71static const char *
72inet_ntop4(const u_char *src, char *dst, size_t size) 72inet_ntop4(const u_char *src, char *dst, size_t size)
73{ 73{
74 static const char fmt[] = "%u.%u.%u.%u";
75 char tmp[sizeof "255.255.255.255"]; 74 char tmp[sizeof "255.255.255.255"];
76 int l; 75 int l;
77 76
78 l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]); 77 l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
78 src[0], src[1], src[2], src[3]);
79 if (l <= 0 || l >= size) { 79 if (l <= 0 || l >= size) {
80 errno = ENOSPC; 80 errno = ENOSPC;
81 return (NULL); 81 return (NULL);