Commit 48054086 authored by Kristian Lyngstol's avatar Kristian Lyngstol

Verify range of port numbers before using them

Fixes #1035
parent a0e3078f
varnishtest "Test case for #1035"
varnish v1 -arg "-a 127.0.0.1:80 -b localhost:8080"
varnish v1 -cliok "param.set listen_address 127.0.0.1:80"
varnish v1 -clierr 106 "param.set listen_address 127.0.0.1:65540"
varnish v1 -clierr 106 "param.set listen_address 127.0.0.1:65536"
varnish v1 -clierr 106 "param.set listen_address 127.0.0.1:-1"
varnish v1 -cliok "param.set listen_address 127.0.0.1:65535"
......@@ -135,6 +135,7 @@ VSS_resolve(const char *addr, const char *port, struct vss_addr ***vap)
struct addrinfo hints, *res0, *res;
struct vss_addr **va;
int i, ret;
long int ptst;
char *adp, *hop;
*vap = NULL;
......@@ -148,8 +149,12 @@ VSS_resolve(const char *addr, const char *port, struct vss_addr ***vap)
if (adp == NULL)
ret = getaddrinfo(addr, port, &hints, &res0);
else
else {
ptst = strtol(adp,NULL,10);
if (ptst < 0 || ptst > 65535)
return(0);
ret = getaddrinfo(hop, adp, &hints, &res0);
}
free(hop);
free(adp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment