1 Star 0 Fork 39

zhengxiaoxiao/gnutls

forked from src-openEuler/gnutls 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-ipv6-handshake-failed.patch 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
zhengxiaoxiao 提交于 2023-07-20 21:13 . update to 3.8.0
From 93a6a9a753c541e04875648cf5671e422e4621df Mon Sep 17 00:00:00 2001
From: lvying <lvying6@huawei.com>
Date: Sat, 8 Jun 2019 22:36:10 -0400
Subject: [PATCH] fix ipv6 handshake failed
reason: fix ipv6 handshake failed
Signed-off-by: lvying <lvying6@huawei.com>
---
lib/ext/server_name.c | 4 +++-
lib/str.h | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/ext/server_name.c b/lib/ext/server_name.c
index 259dc99..f61c1f2 100644
--- a/lib/ext/server_name.c
+++ b/lib/ext/server_name.c
@@ -112,7 +112,9 @@ _gnutls_server_name_recv_params(gnutls_session_t session,
DECR_LEN(data_size, len);
if (type == 0) { /* NAME_DNS */
- if (!_gnutls_dnsname_is_valid((char *)p, len)) {
+ _gnutls_debug_log("HSK[%p]: recieve server name: '%.*s'\n", session, len, p);
+ /* fix ipv6 format server name invaild problem */
+ if (!_gnutls_dnsname_is_valid((char*)p, len) && !_gnutls_ipv6_is_valid((char*)p, len)) {
_gnutls_handshake_log
("HSK[%p]: Server name is not acceptable: '%.*s'\n",
session, (int)len, p);
diff --git a/lib/str.h b/lib/str.h
index 9f0e7d6..e0bca4b 100644
--- a/lib/str.h
+++ b/lib/str.h
@@ -60,6 +60,16 @@ inline static unsigned _gnutls_str_is_print(const char *str, unsigned size)
return 1;
}
+inline static unsigned _gnutls_ipv6_is_valid(const char *str, unsigned size)
+{
+ unsigned i;
+ for (i=0;i<size;i++) {
+ if (!(c_isalnum(str[i]) || str[i] == ':' || str[i] == '%' || str[i] == '.'))
+ return 0;
+ }
+ return 1;
+}
+
inline static unsigned _gnutls_dnsname_is_valid(const char *str, unsigned size)
{
unsigned i;
--
2.19.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhengxiaoxiaoGitee/gnutls.git
git@gitee.com:zhengxiaoxiaoGitee/gnutls.git
zhengxiaoxiaoGitee
gnutls
gnutls
master

搜索帮助