From 68fc1d7c1076faae035414007b5b47a107c141ea Mon Sep 17 00:00:00 2001 From: drawing Date: Fri, 7 Jul 2023 18:09:07 +0800 Subject: [PATCH 1/2] fix complie error: specified bound depends on the length of the source argument --- src/tls/xqc_tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tls/xqc_tls.c b/src/tls/xqc_tls.c index 52ff46779..5f1f20078 100644 --- a/src/tls/xqc_tls.c +++ b/src/tls/xqc_tls.c @@ -169,7 +169,7 @@ xqc_tls_set_alpn(SSL *ssl, const char *alpn) * the rest bytes, set the last byte with '\0' */ p_alpn[0] = alpn_len; - strncpy(&p_alpn[1], alpn, protos_len); + memcpy(&p_alpn[1], alpn, alpn_len); p_alpn[protos_len] = '\0'; SSL_set_alpn_protos(ssl, p_alpn, protos_len); From 2d5558d8b003179bbf8cbf6cb4df074521a953db Mon Sep 17 00:00:00 2001 From: Bobo Date: Mon, 10 Jul 2023 15:43:20 +0800 Subject: [PATCH 2/2] fix stringop-overflow complie error fix stringop-overflow complie error --- src/transport/xqc_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transport/xqc_client.c b/src/transport/xqc_client.c index 6114e207c..25d35fe45 100644 --- a/src/transport/xqc_client.c +++ b/src/transport/xqc_client.c @@ -160,7 +160,7 @@ xqc_client_create_tls(xqc_connection_t *conn, const xqc_conn_ssl_config_t *conn_ ret = -XQC_EMALLOC; goto end; } - strncpy(cfg.alpn, alpn, alpn_cap); + memcpy(cfg.alpn, alpn, alpn_cap); /* copy hostname */ host_cap = strlen(hostname) + 1; @@ -170,7 +170,7 @@ xqc_client_create_tls(xqc_connection_t *conn, const xqc_conn_ssl_config_t *conn_ ret = -XQC_EMALLOC; goto end; } - strncpy(cfg.hostname, hostname, host_cap); + memcpy(cfg.hostname, hostname, host_cap); /* encode local transport parameters, and set to tls config */ cfg.trans_params = tp_buf;