summaryrefslogtreecommitdiffstats
path: root/lib/libc/net
diff options
context:
space:
mode:
authoritojun <itojun@FreeBSD.org>2000-07-09 06:10:01 +0000
committeritojun <itojun@FreeBSD.org>2000-07-09 06:10:01 +0000
commit363b5efd7aac1c44f8ca46456de96c58f07d65da (patch)
treeefb083eda034747b214770511730f4bb376b584b /lib/libc/net
parent1fd6b9aaf72613aaa86577abdd2d0b1518dc5f76 (diff)
downloadFreeBSD-src-363b5efd7aac1c44f8ca46456de96c58f07d65da.zip
FreeBSD-src-363b5efd7aac1c44f8ca46456de96c58f07d65da.tar.gz
reject empty scopeid. use strtoul() for checking all-numericness of
portname. explicitly reject empty numeric portname. sync with kame. based on comments from itohy@netbsd.org
Diffstat (limited to 'lib/libc/net')
-rw-r--r--lib/libc/net/getaddrinfo.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 44a745f..f44a14d 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1,5 +1,5 @@
/* $FreeBSD$ */
-/* $KAME: getaddrinfo.c,v 1.10 2000/07/05 02:59:28 itojun Exp $ */
+/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -359,13 +359,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
@@ -1171,6 +1174,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
OpenPOWER on IntegriCloud