public inbox for ell@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj at gmail.com>
To: ell at lists.01.org
Subject: [PATCH 1/2] cert-crypto: pragma false positive (-Wmaybe-uninitialized)
Date: Fri, 10 Jun 2022 10:11:31 -0700	[thread overview]
Message-ID: <20220610171132.334641-1-prestwoj@gmail.com> (raw)

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

On musl-gcc 'bmpstring' was detected as maybe uninitialized. This
is actually a false positive since the usage is guarded by
if (p_len) but the compiler isn't aware. Pragma to ignore this
warning.

ell/cert-crypto.c: In function 'cert_pkcs12_pbkdf':
ell/cert-crypto.c:246:17: error: 'bmpstring' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  246 |                 explicit_bzero(bmpstring, passwd_len);
---
 ell/cert-crypto.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ell/cert-crypto.c b/ell/cert-crypto.c
index cc312e2..e6e8876 100644
--- a/ell/cert-crypto.c
+++ b/ell/cert-crypto.c
@@ -236,6 +236,8 @@ uint8_t *cert_pkcs12_pbkdf(const char *password,
 		ptr += s_len + salt_len - j;
 	}
 
+_Pragma("GCC diagnostic push")
+_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
 	if (p_len) {
 		for (j = passwd_len; j < p_len;
 					j += passwd_len, ptr += passwd_len)
@@ -246,6 +248,7 @@ uint8_t *cert_pkcs12_pbkdf(const char *password,
 		explicit_bzero(bmpstring, passwd_len);
 		l_free(bmpstring);
 	}
+_Pragma("GCC diagnostic pop")
 
 	key = l_malloc(key_len + hash->len);
 
-- 
2.34.1

             reply	other threads:[~2022-06-10 17:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 17:11 James Prestwood [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-10 17:16 [PATCH 1/2] cert-crypto: pragma false positive (-Wmaybe-uninitialized) Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610171132.334641-1-prestwoj@gmail.com \
    --to=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox