Uninitialized variable l results in cert length mismatch error

An local var `l` in gmtls_construct_client_certificate is uninitialized,
which leads to an cert length mismatch error.

GMTLS handshake using SM2-WITH-SMS4-SM3 cipher suite will be failed due
to this issue.

My editor automatically removed some trailing spaces when I fixed this
bug. So some lines modified in `statem_gmtls.c` are insignificant.
Please ignore them.
This commit is contained in:
Feng Jie
2019-09-19 18:30:47 +08:00
parent a097e49719
commit 237f895ef1

View File

@@ -1339,7 +1339,7 @@ int gmtls_construct_client_certificate(SSL *s)
int al = -1;
unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth;
unsigned char *p;
int l;
int l = 3 + SSL_HM_HEADER_LENGTH(s);
if (alg_a & SSL_aSM2) {
if (!gmtls_construct_sm2_certs(s, &l)) {