case AF_INET:
return (inet_pton4(src, (unsigned char *)dst));
#ifdef ENABLE_IPV6
-#ifndef AF_INET6
-#define AF_INET6 (AF_MAX+1) /* just to let this compile */
-#endif
case AF_INET6:
return (inet_pton6(src, (unsigned char *)dst));
#endif
if((pch = strchr(digits, ch)) != NULL) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
+ if(saw_digit && *tp == 0)
+ return (0);
if(val > 255)
return (0);
*tp = (unsigned char)val;
}
if(octets < 4)
return (0);
- /* bcopy(tmp, dst, INADDRSZ); */
memcpy(dst, tmp, INADDRSZ);
return (1);
}
if(pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
- if(val > 0xffff)
+ if(++saw_xdigit > 4)
return (0);
- saw_xdigit = 1;
continue;
}
if(ch == ':') {
const long n = tp - colonp;
long i;
+ if(tp == endp)
+ return (0);
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
if(tp != endp)
return (0);
- /* bcopy(tmp, dst, IN6ADDRSZ); */
memcpy(dst, tmp, IN6ADDRSZ);
return (1);
}