summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritojun <>2002-08-23 16:27:31 +0000
committeritojun <>2002-08-23 16:27:31 +0000
commitf6d43c698bc42f8a17e2568f70c54b9a2023b1d8 (patch)
treeefa4c64878847be4e32ada78ec64177126f7f22d
parent2f57fab691d36737bcf6e8db544d8562e37b4de0 (diff)
downloadopenbsd-f6d43c698bc42f8a17e2568f70c54b9a2023b1d8.tar.gz
openbsd-f6d43c698bc42f8a17e2568f70c54b9a2023b1d8.tar.bz2
openbsd-f6d43c698bc42f8a17e2568f70c54b9a2023b1d8.zip
deal with negative return value from snprintf.
-rw-r--r--src/lib/libc/net/inet_ntop.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/net/inet_ntop.c b/src/lib/libc/net/inet_ntop.c
index 5293e80fc0..adce61c1d4 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.4 2002/08/19 03:01:54 itojun Exp $ */ 1/* $OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Exp $ */
2 2
3/* Copyright (c) 1996 by Internet Software Consortium. 3/* Copyright (c) 1996 by Internet Software Consortium.
4 * 4 *
@@ -20,7 +20,7 @@
20#if 0 20#if 0
21static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $"; 21static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $";
22#else 22#else
23static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.4 2002/08/19 03:01:54 itojun Exp $"; 23static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Exp $";
24#endif 24#endif
25#endif /* LIBC_SCCS and not lint */ 25#endif /* LIBC_SCCS and not lint */
26 26
@@ -88,8 +88,10 @@ inet_ntop4(src, dst, size)
88{ 88{
89 static const char fmt[] = "%u.%u.%u.%u"; 89 static const char fmt[] = "%u.%u.%u.%u";
90 char tmp[sizeof "255.255.255.255"]; 90 char tmp[sizeof "255.255.255.255"];
91 int l;
91 92
92 if (snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]) >= size) { 93 l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
94 if (l <= 0 || l >= size) {
93 errno = ENOSPC; 95 errno = ENOSPC;
94 return (NULL); 96 return (NULL);
95 } 97 }