ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cert: Fix warning of possible uninitialized var
@ 2021-01-18 18:20 Brian Gix
  2021-01-22 16:15 ` Denis Kenzior
  2021-01-25 16:34 ` Denis Kenzior
  0 siblings, 2 replies; 5+ messages in thread
From: Brian Gix @ 2021-01-18 18:20 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1484 bytes --]

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(-)

diff --git a/ell/cert-crypto.c b/ell/cert-crypto.c
index 6eb4e14..838d5b5 100644
--- a/ell/cert-crypto.c
+++ b/ell/cert-crypto.c
@@ -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);
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cert: Fix warning of possible uninitialized var
  2021-01-18 18:20 [PATCH v2] cert: Fix warning of possible uninitialized var Brian Gix
@ 2021-01-22 16:15 ` Denis Kenzior
  2021-01-22 22:29   ` Andrew Zaborowski
  2021-01-25 16:34 ` Denis Kenzior
  1 sibling, 1 reply; 5+ messages in thread
From: Denis Kenzior @ 2021-01-22 16:15 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

Andrew,

On 1/18/21 12:20 PM, Brian Gix wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cert: Fix warning of possible uninitialized var
  2021-01-22 16:15 ` Denis Kenzior
@ 2021-01-22 22:29   ` Andrew Zaborowski
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Zaborowski @ 2021-01-22 22:29 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

Hi Denis,

On Fri, 22 Jan 2021 at 17:15, Denis Kenzior <denkenz@gmail.com> wrote:
> Do you have any comments on this patch or should I take it in?

No comments, it looks good to me.

Best regards

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cert: Fix warning of possible uninitialized var
  2021-01-18 18:20 [PATCH v2] cert: Fix warning of possible uninitialized var Brian Gix
  2021-01-22 16:15 ` Denis Kenzior
@ 2021-01-25 16:34 ` Denis Kenzior
  2021-01-25 17:40   ` Gix, Brian
  1 sibling, 1 reply; 5+ messages in thread
From: Denis Kenzior @ 2021-01-25 16:34 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

Hi Brian,

On 1/18/21 12:20 PM, Brian Gix wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cert: Fix warning of possible uninitialized var
  2021-01-25 16:34 ` Denis Kenzior
@ 2021-01-25 17:40   ` Gix, Brian
  0 siblings, 0 replies; 5+ messages in thread
From: Gix, Brian @ 2021-01-25 17:40 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

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


On Mon, 2021-01-25 at 10:34 -0600, Denis Kenzior wrote:
> Hi Brian,
> 
> On 1/18/21 12:20 PM, Brian Gix wrote:
> > 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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-25 17:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 18:20 [PATCH v2] cert: Fix warning of possible uninitialized var Brian Gix
2021-01-22 16:15 ` Denis Kenzior
2021-01-22 22:29   ` Andrew Zaborowski
2021-01-25 16:34 ` Denis Kenzior
2021-01-25 17:40   ` Gix, Brian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).