From 4c5138eadeb3ef267aa4d14839ea68e6c54eb74b Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 20 Apr 2018 10:49:29 +0800 Subject: [PATCH] proxy: allow use of at char in passwords Applies to both http proxy and socks proxy https://github.com/warmcat/libwebsockets/issues/1247 --- lib/libwebsockets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index eb2e917eb..1c609911e 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1770,7 +1770,7 @@ lws_set_proxy(struct lws_vhost *vhost, const char *proxy) if (!strncmp(proxy, "http://", 7)) proxy += 7; - p = strchr(proxy, '@'); + p = strrchr(proxy, '@'); if (p) { /* auth is around */ if ((unsigned int)(p - proxy) > sizeof(authstring) - 1) @@ -1829,7 +1829,7 @@ lws_set_socks(struct lws_vhost *vhost, const char *socks) vhost->socks_user[0] = '\0'; vhost->socks_password[0] = '\0'; - p_at = strchr(socks, '@'); + p_at = strrchr(socks, '@'); if (p_at) { /* auth is around */ if ((unsigned int)(p_at - socks) > (sizeof(user) + sizeof(password) - 2)) {