diff options
| author | Robert Drehmel <robert@FreeBSD.org> | 2002-08-15 21:19:31 +0000 |
|---|---|---|
| committer | Robert Drehmel <robert@FreeBSD.org> | 2002-08-15 21:19:31 +0000 |
| commit | 085f131a15d5a4ee8307b5cfd8c485cd4de7174d (patch) | |
| tree | cd1c9e51eb23323a92ebc36ddc0e35200c7afcfb /lib/libc | |
| parent | f0769ef9fd8d2b49976439bcc0e008c2f57db0b0 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/net/inet_ntop.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/libc/net/inet_ntop.c b/lib/libc/net/inet_ntop.c index 534c968c5bad..93e175cfe1fa 100644 --- a/lib/libc/net/inet_ntop.c +++ b/lib/libc/net/inet_ntop.c @@ -30,8 +30,6 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <string.h> -#define SPRINTF(x) ((socklen_t)sprintf x) - /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. @@ -79,13 +77,12 @@ static const char * inet_ntop4(const u_char *src, char *dst, socklen_t size) { static const char fmt[] = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) { + if ((socklen_t)snprintf(dst, size, fmt, src[0], src[1], src[2], src[3]) + >= size) { errno = ENOSPC; return (NULL); } - strcpy(dst, tmp); return (dst); } @@ -164,7 +161,7 @@ inet_ntop6(const u_char *src, char *dst, socklen_t size) tp += strlen(tp); break; } - tp += SPRINTF((tp, "%x", words[i])); + tp += sprintf(tp, "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == |
