diff options
author | Mystery Man <unknown@mandriva.org> | 2003-10-29 16:07:11 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2003-10-29 16:07:11 +0000 |
commit | fa40f30b4253b1e05c46cc5e0c111176825b7623 (patch) | |
tree | 76cf2d26c0ce0ee7c6a2c1a1a2b65bc4d8e33029 /mdk-stage1/dietlibc/libcruft/inet_pton.c | |
parent | 327bd24f8e4291bd1882de1990dd7339f781a9cb (diff) | |
download | drakx-backup-do-not-use-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar drakx-backup-do-not-use-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.gz drakx-backup-do-not-use-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.bz2 drakx-backup-do-not-use-fa40f30b4253b1e05c46cc5e0c111176825b7623.tar.xz drakx-backup-do-not-use-fa40f30b4253b1e05c46cc5e0c111176825b7623.zip |
This commit was manufactured by cvs2svn to create tag 'Corpo_2_1_1'.Corpo_2_1_1
Diffstat (limited to 'mdk-stage1/dietlibc/libcruft/inet_pton.c')
-rw-r--r-- | mdk-stage1/dietlibc/libcruft/inet_pton.c | 17 |
1 files changed, 11 insertions, 6 deletions
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 <stdlib.h> +#include <sys/socket.h> #include <arpa/inet.h> #include <errno.h> +#include <string.h> +#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; |