[PATCH] Silence 'may be used uninitialized in this function' warnings
Jussi Kivilinna
jussi.kivilinna at iki.fi
Tue Jan 19 19:14:17 CET 2021
* cipher/arcfour.c (selftest): Initialize 'ctx'.
* cipher/ecc-eddsa.c (_gcry_ecc_eddsa_ensure_compact): Initialize
'enc' and 'enclen'.
(_gcry_ecc_eddsa_sign, _gcry_ecc_eddsa_verify): Initialize 'encpklen'.
* mpi/mpi-pow.c (_gcry_mpi_powm): Initialize 'xsize'.
--
Warnings were seen on gcc-s390x build with optimization level -O3.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
cipher/arcfour.c | 2 +-
cipher/ecc-eddsa.c | 8 ++++----
mpi/mpi-pow.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/cipher/arcfour.c b/cipher/arcfour.c
index 9e71857c..909e45b2 100644
--- a/cipher/arcfour.c
+++ b/cipher/arcfour.c
@@ -183,7 +183,7 @@ arcfour_setkey ( void *context, const byte *key, unsigned int keylen,
static const char*
selftest(void)
{
- ARCFOUR_context ctx;
+ ARCFOUR_context ctx = { { 0, }, };
byte scratch[16];
/* Test vector from Cryptlib labeled there: "from the
diff --git a/cipher/ecc-eddsa.c b/cipher/ecc-eddsa.c
index 2a1a8907..63c0ef3f 100644
--- a/cipher/ecc-eddsa.c
+++ b/cipher/ecc-eddsa.c
@@ -154,8 +154,8 @@ _gcry_ecc_eddsa_ensure_compact (gcry_mpi_t value, unsigned int nbits)
const unsigned char *buf;
unsigned int rawmpilen;
gcry_mpi_t x, y;
- unsigned char *enc;
- unsigned int enclen;
+ unsigned char *enc = NULL;
+ unsigned int enclen = 0;
if (!mpi_is_opaque (value))
return GPG_ERR_INV_OBJ;
@@ -699,7 +699,7 @@ _gcry_ecc_eddsa_sign (gcry_mpi_t input, mpi_ec_t ec,
unsigned char *rawmpi = NULL;
unsigned int rawmpilen;
unsigned char *encpk = NULL; /* Encoded public key. */
- unsigned int encpklen;
+ unsigned int encpklen = 0;
mpi_point_struct I; /* Intermediate value. */
gcry_mpi_t a, x, y, r;
int b;
@@ -977,7 +977,7 @@ _gcry_ecc_eddsa_verify (gcry_mpi_t input, mpi_ec_t ec,
int b;
unsigned int tmp;
unsigned char *encpk = NULL; /* Encoded public key. */
- unsigned int encpklen;
+ unsigned int encpklen = 0;
const void *mbuf, *rbuf;
unsigned char *tbuf = NULL;
size_t mlen, rlen;
diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c
index 62b4a808..defd675e 100644
--- a/mpi/mpi-pow.c
+++ b/mpi/mpi-pow.c
@@ -545,7 +545,7 @@ _gcry_mpi_powm (gcry_mpi_t res,
{
mpi_size_t i, j, k;
mpi_ptr_t xp;
- mpi_size_t xsize;
+ mpi_size_t xsize = 0;
int c;
mpi_limb_t e;
mpi_limb_t carry_limb;
--
2.27.0
More information about the Gcrypt-devel
mailing list