From de47eb59bb829423b1d0f47ba13099073999b3cb Mon Sep 17 00:00:00 2001 From: Nicolas Planel Date: Wed, 29 Oct 2003 16:07:11 +0000 Subject: Corporate Server 2.1.1 release --- mdk-stage1/dietlibc/libcruft/inet_pton.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'mdk-stage1/dietlibc/libcruft/inet_pton.c') diff --git a/mdk-stage1/dietlibc/libcruft/inet_pton.c b/mdk-stage1/dietlibc/libcruft/inet_pton.c index d5c17509c..a62785d5f 100644 --- a/mdk-stage1/dietlibc/libcruft/inet_pton.c +++ b/mdk-stage1/dietlibc/libcruft/inet_pton.c @@ -1,6 +1,9 @@ #include +#include #include #include +#include +#include "dietfeatures.h" static unsigned int scan_ip6(const char *s,char ip[16]) { @@ -9,8 +12,8 @@ static unsigned int scan_ip6(const char *s,char ip[16]) unsigned long u; char suffix[16]; - int prefixlen=0; - int suffixlen=0; + unsigned int prefixlen=0; + unsigned int suffixlen=0; for (i=0; i<16; i++) ip[i]=0; @@ -26,7 +29,7 @@ static unsigned int scan_ip6(const char *s,char ip[16]) } { char *tmp; - u=strtol(s,&tmp,16); + u=strtoul(s,&tmp,16); i=tmp-s; } @@ -60,7 +63,7 @@ static unsigned int scan_ip6(const char *s,char ip[16]) i=tmp-s; } if (!i) { - len--; + if (*s) len--; break; } if (suffixlen+prefixlen<=12 && s[i]=='.') { @@ -83,12 +86,14 @@ static unsigned int scan_ip6(const char *s,char ip[16]) } int inet_pton(int AF, const char *CP, void *BUF) { + int len; if (AF==AF_INET) { if (!inet_aton(CP,(struct in_addr*)BUF)) return 0; } else if (AF==AF_INET6) { - if (CP[scan_ip6(CP,BUF)]) - return 0; + if (CP[len=scan_ip6(CP,BUF)]) + if (CP[len]!='%') /* allow "fe80::220:e0ff:fe69:ad92%eth0" */ + return 0; } else { errno=EAFNOSUPPORT; return -1; -- cgit v1.2.1