diff options
author | Nicolas Planel <nplanel@mandriva.com> | 2003-10-29 16:07:11 +0000 |
---|---|---|
committer | Nicolas Planel <nplanel@mandriva.com> | 2003-10-29 16:07:11 +0000 |
commit | de47eb59bb829423b1d0f47ba13099073999b3cb (patch) | |
tree | 827f35c4666e15ec66edae7c1fa05d963324602b /mdk-stage1/dietlibc/libcruft/inet_pton.c | |
parent | 1fece42e9c460ca017fc4facad380f05163d8977 (diff) | |
download | drakx-backup-do-not-use-de47eb59bb829423b1d0f47ba13099073999b3cb.tar drakx-backup-do-not-use-de47eb59bb829423b1d0f47ba13099073999b3cb.tar.gz drakx-backup-do-not-use-de47eb59bb829423b1d0f47ba13099073999b3cb.tar.bz2 drakx-backup-do-not-use-de47eb59bb829423b1d0f47ba13099073999b3cb.tar.xz drakx-backup-do-not-use-de47eb59bb829423b1d0f47ba13099073999b3cb.zip |
Corporate Server 2.1.1 releasetopic/Corpo_2_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; |