diff --git a/client/http_resolve_host.c b/client/http_resolve_host.c index cac9198d..8a117b5c 100644 --- a/client/http_resolve_host.c +++ b/client/http_resolve_host.c @@ -237,49 +237,49 @@ resolve_ip_http(fko_cli_options_t *options) close(sock); #endif - /* Move to the end of the HTTP header and to the start of the content. - */ - ndx = strstr(http_response, "\r\n\r\n"); - if(ndx == NULL) - { - fprintf(stderr, "Did not find the end of HTTP header.\n"); - return(-1); - } - ndx += 4; - - /* Walk along the content to try to find the end of the IP address. - * Note: We are expecting the content to be just an IP address - * (possibly followed by whitespace or other not-digit value). - */ - for(i=0; i= 0 && o1 <= 255 - && o2 >= 0 && o2 <= 255 - && o3 >= 0 && o3 <= 255 - && o4 >= 0 && o4 <= 255) - { - strlcpy(options->allow_ip_str, ndx, MAX_IPV4_STR_LEN); + ndx = strstr(http_response, "\r\n\r\n"); + if(ndx == NULL) + { + fprintf(stderr, "Did not find the end of HTTP header.\n"); + return(-1); + } + ndx += 4; - if(options->verbose) - printf("Resolved external IP (via http://%s%s) as: %s\n", - url.host, - url.path, - options->allow_ip_str); + /* Walk along the content to try to find the end of the IP address. + * Note: We are expecting the content to be just an IP address + * (possibly followed by whitespace or other not-digit value). + */ + for(i=0; i= 0 && o1 <= 255 + && o2 >= 0 && o2 <= 255 + && o3 >= 0 && o3 <= 255 + && o4 >= 0 && o4 <= 255) + { + strlcpy(options->allow_ip_str, ndx, MAX_IPV4_STR_LEN); + + if(options->verbose) + printf("Resolved external IP (via http://%s%s) as: %s\n", + url.host, + url.path, + options->allow_ip_str); + + return(0); + } + else { fprintf(stderr, "Invalid IP (%s) in HTTP response.\n", ndx); return(-1);