Fixed uiplib to stop parsing IPv6 address when at length part

This commit is contained in:
Joakim Eriksson 2012-01-03 13:32:23 -08:00 committed by Niclas Finne
parent 0ea95c21b3
commit 65edc32de2

View file

@ -57,13 +57,13 @@ uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *ipaddr)
for(len = 0; len < sizeof(uip_ipaddr_t) - 1; addrstr++) {
c = *addrstr;
if(c == ':' || c == '\0' || c == ']') {
if(c == ':' || c == '\0' || c == ']' || c == '/') {
ipaddr->u8[len] = (value >> 8) & 0xff;
ipaddr->u8[len + 1] = value & 0xff;
len += 2;
value = 0;
if(c == '\0' || c == ']') {
if(c == '\0' || c == ']' || c == '/') {
break;
}
@ -88,7 +88,7 @@ uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *ipaddr)
value = (value << 4) + (tmp & 0xf);
}
}
if(c != '\0' && c != ']') {
if(c != '\0' && c != ']' && c != '/') {
PRINTF("uiplib: too large address\n");
return 0;
}