Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix complie error: specified bound depends on the length of the source argument #312

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tls/xqc_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/transport/xqc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down