From ca6f5be56869f06c5fe60e242c9d0f637b26485c Mon Sep 17 00:00:00 2001 From: yangwei Date: Mon, 31 Jul 2023 00:49:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(parse=5Fserver=5Fname=5Fexte?= =?UTF-8?q?nsion):=20=E5=A2=9E=E5=8A=A0sni=E9=95=BF=E5=BA=A6=E5=88=A4?= =?UTF-8?q?=E6=96=AD=EF=BC=8C=E5=90=8C=E6=97=B6=E8=A7=A3=E6=9E=90=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=BC=82=E5=B8=B8=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E5=B7=B2=E7=94=B3=E8=AF=B7sni=E5=86=85?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tsg_ssl_utils.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tsg_ssl_utils.cpp b/src/tsg_ssl_utils.cpp index 96ff144..634dae9 100644 --- a/src/tsg_ssl_utils.cpp +++ b/src/tsg_ssl_utils.cpp @@ -179,7 +179,7 @@ static char* parse_server_name_extension(const unsigned char* buff, size_t buff while (pos + 3 < buff_len) { size_t len = ((size_t)buff[pos + 1] << 8) + (size_t)buff[pos + 2]; - if (pos + 3 + len > buff_len) + if (len == 0 || pos + 3 + len > buff_len) { *result = CHELLO_PARSE_INVALID_FORMAT; return NULL; @@ -198,6 +198,11 @@ static char* parse_server_name_extension(const unsigned char* buff, size_t buff } if (pos != buff_len) { + if(sni!=NULL) + { + free(sni); + sni = NULL; + } *result = CHELLO_PARSE_INVALID_FORMAT; } return sni;