diff options
author | 2002-08-23 16:27:31 +0000 | |
---|---|---|
committer | 2002-08-23 16:27:31 +0000 | |
commit | 1868dddf65032b2aeb64a7880e077964d44fe07e (patch) | |
tree | 9f02225fb2febf97cde07b7c7b4005a726062a35 /lib/libc/net | |
parent | o) fix .Sh usage; (diff) | |
download | wireguard-openbsd-1868dddf65032b2aeb64a7880e077964d44fe07e.tar.xz wireguard-openbsd-1868dddf65032b2aeb64a7880e077964d44fe07e.zip |
deal with negative return value from snprintf.
Diffstat (limited to 'lib/libc/net')
-rw-r--r-- | lib/libc/net/inet_ntop.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/net/inet_ntop.c b/lib/libc/net/inet_ntop.c index 5293e80fc0b..adce61c1d46 100644 --- a/lib/libc/net/inet_ntop.c +++ b/lib/libc/net/inet_ntop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet_ntop.c,v 1.4 2002/08/19 03:01:54 itojun Exp $ */ +/* $OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. * @@ -20,7 +20,7 @@ #if 0 static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $"; #else -static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.4 2002/08/19 03:01:54 itojun Exp $"; +static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -88,8 +88,10 @@ inet_ntop4(src, dst, size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; + int l; - if (snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]) >= size) { + l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]); + if (l <= 0 || l >= size) { errno = ENOSPC; return (NULL); } |