Rebuild with utf-8 encoding
[privoxy.git] / urlmatch.c
index b5001af..c731ec3 100644 (file)
@@ -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)
    {