diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-10-27 13:54:27 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-10-27 23:31:31 +0200 |
commit | efc286b7a62af0568fdcbf3c68791c9955182128 (patch) | |
tree | 77bc86253b01f9023f4244997fed554eb2b1ce41 /lib/noproxy.c | |
parent | fc8d6b2370bdbf1c4002c4aecb856a0b4f419b62 (diff) | |
download | curl-efc286b7a62af0568fdcbf3c68791c9955182128.tar.gz |
noproxy: also match with adjacent comma
If the host name is an IP address and the noproxy string contained that
IP address with a following comma, it would erroneously not match.
Extended test 1614 to verify this combo as well.
Reported-by: Henning Schild
Fixes #9813
Closes #9814
Diffstat (limited to 'lib/noproxy.c')
-rw-r--r-- | lib/noproxy.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/noproxy.c b/lib/noproxy.c index 3409dab6f..58bc69a2d 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -192,18 +192,22 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy) /* FALLTHROUGH */ case TYPE_IPV6: { const char *check = token; - char *slash = strchr(check, '/'); + char *slash; unsigned int bits = 0; char checkip[128]; + if(tokenlen >= sizeof(checkip)) + /* this cannot match */ + break; + /* copy the check name to a temp buffer */ + memcpy(checkip, check, tokenlen); + checkip[tokenlen] = 0; + check = checkip; + + slash = strchr(check, '/'); /* if the slash is part of this token, use it */ - if(slash && (slash < &check[tokenlen])) { + if(slash) { bits = atoi(slash + 1); - /* copy the check name to a temp buffer */ - if(tokenlen >= sizeof(checkip)) - break; - memcpy(checkip, check, tokenlen); - checkip[ slash - check ] = 0; - check = checkip; + *slash = 0; /* null terminate there */ } if(type == TYPE_IPV6) match = Curl_cidr6_match(name, check, bits); |