diff options
| author | tedu <> | 2014-05-17 18:16:14 +0000 | 
|---|---|---|
| committer | tedu <> | 2014-05-17 18:16:14 +0000 | 
| commit | afdc6eddfe60eb533fda183ea52276823ad248c9 (patch) | |
| tree | 3568993d7214fb09929d95105a2eaf99bbbcd4ca /src/lib/libc | |
| parent | 0e64a86aa704c838b78e66bd2cd1f53176c49326 (diff) | |
| download | openbsd-afdc6eddfe60eb533fda183ea52276823ad248c9.tar.gz openbsd-afdc6eddfe60eb533fda183ea52276823ad248c9.tar.bz2 openbsd-afdc6eddfe60eb533fda183ea52276823ad248c9.zip | |
correctly match size and buffer. from enh at google
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/net/inet_ntop.c | 6 | 
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) | |||
| 71 | static const char * | 71 | static const char * | 
| 72 | inet_ntop4(const u_char *src, char *dst, size_t size) | 72 | inet_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); | 
