From 6ad05e0db78b83910934edeee80f83058c6a8334 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 27 Dec 2015 12:53:39 +0000 Subject: [PATCH] acl_addr(): Properly parse acl directives with ports when compiled with HAVE_RFC2553 Previously the port wasn't removed from the host and in case of 'permit-access 127.0.0.1 example.org:80' Privoxy would try (and fail) to resolve "example.org:80" instead of example.org. Reported by Pak Chan on ijbswa-users@. --- filters.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/filters.c b/filters.c index 55fdc3d1..4b4f33e9 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.194 2015/08/21 10:58:53 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.195 2015/12/27 12:46:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -386,13 +386,19 @@ int acl_addr(const char *aspec, struct access_control_addr *aca) { p = strchr(acl_spec, ':'); } + if (p != NULL) + { + assert(*p == ':'); + *p = '\0'; + p++; + } #ifdef HAVE_RFC2553 memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - i = getaddrinfo(acl_spec, ((p) ? ++p : NULL), &hints, &result); + i = getaddrinfo(acl_spec, p, &hints, &result); if (i != 0) { @@ -411,7 +417,6 @@ int acl_addr(const char *aspec, struct access_control_addr *aca) { char *endptr; - *p++ = '\0'; port = strtol(p, &endptr, 10); if (port <= 0 || port > 65535 || *endptr != '\0') -- 2.39.2