summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-07-09 04:48:36 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-07-09 04:48:36 +0000
commitd5be48b42274b6ae153e9a71324b1714edc41c8f (patch)
tree4bae5e274fae4910751e2602d534b86cf692a3c8
parent80e1dfc32db3427f9587dea891f1f6d158f34fc8 (diff)
reject empty scopeid/numeric portname. sync with kame.
-rw-r--r--lib/libc/net/getaddrinfo.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index c64e838acc8..a443d8c9f21 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: getaddrinfo.c,v 1.24 2000/07/05 03:00:55 itojun Exp $ */
-/* $KAME: getaddrinfo.c,v 1.25 2000/07/05 02:59:28 itojun Exp $ */
+/* $OpenBSD: getaddrinfo.c,v 1.25 2000/07/09 04:48:35 itojun Exp $ */
+/* $KAME: getaddrinfo.c,v 1.30 2000/07/09 04:37:25 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -288,13 +288,16 @@ static int
str_isnumber(p)
const char *p;
{
- const char *q = (const char *)p;
- while (*q) {
- if (!isdigit(*q))
- return NO;
- q++;
- }
- return YES;
+ char *ep;
+
+ if (*p == '\0')
+ return NO;
+ ep = NULL;
+ (void)strtoul(p, &ep, 10);
+ if (ep && *ep == '\0')
+ return YES;
+ else
+ return NO;
}
int
@@ -973,6 +976,10 @@ ip6_str2scopeid(scope, sin6)
struct in6_addr *a6 = &sin6->sin6_addr;
char *ep;
+ /* empty scopeid portion is invalid */
+ if (*scope == '\0')
+ return -1;
+
if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) {
/*
* We currently assume a one-to-one mapping between links