X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=c731ec3b1336f20e5065c908f96c4bcf1cebbb73;hp=b5001af5777f5fad58d6f3a62307d88c1a17aecc;hb=68b650b4265d93d1e1bbbbe7726c84df39e53d0e;hpb=9be0727edbc5de0cfdbe1c9f7c244e1530f82fee diff --git a/urlmatch.c b/urlmatch.c index b5001af5..c731ec3b 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.72 2012/07/23 12:42:53 fabiankeil Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.74 2012/12/07 12:49:20 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -382,9 +382,18 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr if (port != NULL) { /* Contains port */ + char *endptr; + long parsed_port; /* Terminate hostname and point to start of port string */ *port++ = '\0'; - http->port = atoi(port); + parsed_port = strtol(port, &endptr, 10); + if ((parsed_port <= 0) || (parsed_port > 65535) || (*endptr != '\0')) + { + log_error(LOG_LEVEL_ERROR, "Invalid port in URL: %s.", url); + freez(buf); + return JB_ERR_PARSE; + } + http->port = (int)parsed_port; } else { @@ -793,7 +802,7 @@ static jb_err compile_host_pattern(struct url_spec *url, const char *host_patter if (url->dcount < 0) { free_url_spec(url); - return JB_ERR_MEMORY; + return JB_ERR_PARSE; } else if (url->dcount != 0) {