summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Jodeit <moritz@cvs.openbsd.org>2005-05-02 17:38:42 +0000
committerMoritz Jodeit <moritz@cvs.openbsd.org>2005-05-02 17:38:42 +0000
commitf05ba942ed8ca9328c30e6b262e6cf2ed8fc31a4 (patch)
treee2e9d7107be195b5b878690681765a3351fedcfa
parentb6bfa466061965778fc9f6a90e4896c75c9796ef (diff)
be more careful with snprintf. ok millert@
-rw-r--r--lib/libc/net/gethostnamadr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index c643f2382ae..f0be24143c7 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -48,7 +48,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.61 2005/03/30 02:58:28 tedu Exp $";
+static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.62 2005/05/02 17:38:41 moritz Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -702,7 +702,7 @@ gethostbyaddr(const char *addr, int len, int af)
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
i = snprintf(qp, ep - qp, "%x.%x.",
uaddr[n] & 0xf, (uaddr[n] >> 4) & 0xf);
- if (i <= 0) {
+ if (i <= 0 || i >= ep - qp) {
errno = EINVAL;
h_errno = NETDB_INTERNAL;
return (NULL);