diff options
author | itojun <> | 2000-07-09 04:48:35 +0000 |
---|---|---|
committer | itojun <> | 2000-07-09 04:48:35 +0000 |
commit | 5486a7dcd17f8346b3c3d057f7c6887934adb1e8 (patch) | |
tree | cee88af93c45fdb0863ef84ca1f8a956b38d3b31 /src | |
parent | ea17318c46894b9d7496a82d6a016f28b5421cd2 (diff) | |
download | openbsd-5486a7dcd17f8346b3c3d057f7c6887934adb1e8.tar.gz openbsd-5486a7dcd17f8346b3c3d057f7c6887934adb1e8.tar.bz2 openbsd-5486a7dcd17f8346b3c3d057f7c6887934adb1e8.zip |
reject empty scopeid/numeric portname. sync with kame.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/net/getaddrinfo.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c index c64e838acc..a443d8c9f2 100644 --- a/src/lib/libc/net/getaddrinfo.c +++ b/src/lib/libc/net/getaddrinfo.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* $OpenBSD: getaddrinfo.c,v 1.24 2000/07/05 03:00:55 itojun Exp $ */ | 1 | /* $OpenBSD: getaddrinfo.c,v 1.25 2000/07/09 04:48:35 itojun Exp $ */ |
2 | /* $KAME: getaddrinfo.c,v 1.25 2000/07/05 02:59:28 itojun Exp $ */ | 2 | /* $KAME: getaddrinfo.c,v 1.30 2000/07/09 04:37:25 itojun Exp $ */ |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
@@ -288,13 +288,16 @@ static int | |||
288 | str_isnumber(p) | 288 | str_isnumber(p) |
289 | const char *p; | 289 | const char *p; |
290 | { | 290 | { |
291 | const char *q = (const char *)p; | 291 | char *ep; |
292 | while (*q) { | 292 | |
293 | if (!isdigit(*q)) | 293 | if (*p == '\0') |
294 | return NO; | 294 | return NO; |
295 | q++; | 295 | ep = NULL; |
296 | } | 296 | (void)strtoul(p, &ep, 10); |
297 | return YES; | 297 | if (ep && *ep == '\0') |
298 | return YES; | ||
299 | else | ||
300 | return NO; | ||
298 | } | 301 | } |
299 | 302 | ||
300 | int | 303 | int |
@@ -973,6 +976,10 @@ ip6_str2scopeid(scope, sin6) | |||
973 | struct in6_addr *a6 = &sin6->sin6_addr; | 976 | struct in6_addr *a6 = &sin6->sin6_addr; |
974 | char *ep; | 977 | char *ep; |
975 | 978 | ||
979 | /* empty scopeid portion is invalid */ | ||
980 | if (*scope == '\0') | ||
981 | return -1; | ||
982 | |||
976 | if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) { | 983 | if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) { |
977 | /* | 984 | /* |
978 | * We currently assume a one-to-one mapping between links | 985 | * We currently assume a one-to-one mapping between links |