From 16efbf49a236d00fdecf161a5d689a2813f508db Mon Sep 17 00:00:00 2001
From: JoonCheol Park <jooncheol@gmail.com>
Date: Mon, 18 Feb 2019 15:59:29 +0400
Subject: [PATCH] socks5: fix remain dst buffer length when calls lws_strncpy

---
 lib/roles/http/client/client-handshake.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c
index d3cacb8c..617e9e1a 100644
--- a/lib/roles/http/client/client-handshake.c
+++ b/lib/roles/http/client/client-handshake.c
@@ -1017,14 +1017,14 @@ void socks_generate_msg(struct lws *wsi, enum socks_msg_type type,
 		pt->serv_buf[len++] = n;
 		/* user name */
 		lws_strncpy((char *)&pt->serv_buf[len], wsi->vhost->socks_user,
-			context->pt_serv_buf_size - len + 1);
+			context->pt_serv_buf_size - len);
 		len += n;
 		/* length of the password */
 		pt->serv_buf[len++] = passwd_len;
 		/* password */
 		lws_strncpy((char *)&pt->serv_buf[len],
 			    wsi->vhost->socks_password,
-			    context->pt_serv_buf_size - len + 1);
+			    context->pt_serv_buf_size - len);
 		len += passwd_len;
 		break;
 
@@ -1044,7 +1044,7 @@ void socks_generate_msg(struct lws *wsi, enum socks_msg_type type,
 
 		/* the address we tell SOCKS proxy to connect to */
 		lws_strncpy((char *)&(pt->serv_buf[len]), wsi->stash->address,
-			context->pt_serv_buf_size - len + 1);
+			context->pt_serv_buf_size - len);
 		len += strlen(wsi->stash->address);
 		net_num = htons(wsi->c_port);
 
-- 
GitLab