cert: Fix warning of possible uninitialized var
PATCH v2 1/1 cert: Fix warning of possible uninitialized var
ell/cert-crypto.c: In function ‘cert_pkcs12_pbkdf’:ell/cert-crypto.c:244:3: error: ‘bmpstring’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
244 | explicit_bzero(bmpstring, passwd_len);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
ell/cert-crypto.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)ell/cert-crypto.c +6 -4
@@ -198,7 +198,8 @@ uint8_t *cert_pkcs12_pbkdf(const char *password,/* Documented as v(ceiling(s/v)), usually will just equal v */ unsigned int s_len = (salt_len + hash->v -1 ) & ~(hash->v -1 );/* Documented as p(ceiling(s/p)), usually will just equal v */ -unsigned int p_len = (passwd_len + hash->v -1 ) & ~(hash->v -1 ); +unsigned int p_len = password ? + (passwd_len + hash->v -1 ) & ~(hash->v -1 ) :0 ;uint8_t di[hash->v + s_len + p_len];uint8_t *ptr;unsigned int j;
@@ -235,10 +236,11 @@ uint8_t *cert_pkcs12_pbkdf(const char *password, ptr += s_len + salt_len - j; } -for (j = passwd_len; j < p_len; j += passwd_len, ptr += passwd_len) -memcpy (ptr, bmpstring, passwd_len); -if (p_len) { +for (j = passwd_len; j < p_len; + j += passwd_len, ptr += passwd_len) +memcpy (ptr, bmpstring, passwd_len); +memcpy (ptr, bmpstring, p_len + passwd_len - j);explicit_bzero (bmpstring, passwd_len);
Signature · 1 line
2.25.4
Andrew,
Quoted 8 lines · Brian Gix
ell/cert-crypto.c: In function ‘cert_pkcs12_pbkdf’:ell/cert-crypto.c:244:3: error: ‘bmpstring’ may be used uninitialized in this function [-Werror=maybe-uninitialized]244 | explicit_bzero(bmpstring, passwd_len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- ell/cert-crypto.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Do you have any comments on this patch or should I take it in?
Regards,
-Denis
Hi Denis,
Quoted 1 line · Denis Kenzior
Do you have any comments on this patch or should I take it in?
No comments, it looks good to me.
Best regards
Denis Kenzior
AppliedHi Brian,
Quoted 8 lines · Brian Gix
ell/cert-crypto.c: In function ‘cert_pkcs12_pbkdf’:ell/cert-crypto.c:244:3: error: ‘bmpstring’ may be used uninitialized in this function [-Werror=maybe-uninitialized]244 | explicit_bzero(bmpstring, passwd_len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- ell/cert-crypto.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Applied, thanks.
Regards,
-Denis
Gix
Sorry Denis.... In a conf call with Marcel, he suggested the patch in v3 just sent...
Also, if possible, we would like to get a 0.37 version of ELL labeled, since this will be the first working version for us since 0.35, and I need to account for the file name change of pkcs5 --> cert-crypto
Quoted 18 lines · Denis Kenzior
Hi Brian,
Quoted 9 lines · Brian Gix
ell/cert-crypto.c: In function ‘cert_pkcs12_pbkdf’:ell/cert-crypto.c:244:3: error: ‘bmpstring’ may be used uninitialized in this function [-Werror=maybe- uninitialized]244 | explicit_bzero(bmpstring, passwd_len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- ell/cert-crypto.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)Applied, thanks.
Regards,
-Denis