- while (ptr && ptr < end) // Find "NewExternalIPAddress"
- {
- if (*ptr == 'N' && (strncasecmp(ptr, "NewExternalIPAddress", 20) == 0)) break; // find the first 'N'; is this NewExternalIPAddress? if not, keep looking
- ptr++;
- }
- if (ptr == mDNSNULL || ptr >= end) return; // bad or incomplete response
- ptr+=21; // skip over "NewExternalIPAddress>"
- if (ptr >= end) { LogOperation("handleLNTGetExternalAddressResponse: past end of buffer!"); return; }
-
- // find the end of the address and terminate the string so inet_pton() can convert it
- for (addrPtr = ptr; addrPtr && addrPtr < end; addrPtr++) if (*addrPtr == '<') break; // first find the next '<' and count the chars
- if (addrPtr == mDNSNULL || addrPtr >= end) { LogOperation("handleLNTGetExternalAddressResponse: didn't find SOAP URL string"); return; }
- *addrPtr = '\0';
+ while (ptr < end && strncasecmp(ptr, tagname, sizeof(tagname))) ptr++;
+ ptr += sizeof(tagname); // Skip over "NewExternalIPAddress"
+ while (ptr < end && *ptr != '>') ptr++;
+ ptr += 1; // Skip over ">"
+ // Find the end of the address and terminate the string so inet_pton() can convert it
+ addrend = ptr;
+ while (addrend < end && (mdnsIsDigit(*addrend) || *addrend == '.')) addrend++;
+ if (addrend >= end) return;
+ *addrend = 0;