[PATCH 2/3] md: clear context with wipememory to avoid false warning

Jussi Kivilinna jussi.kivilinna at iki.fi
Mon Oct 25 20:02:13 CEST 2021


* cipher/md.c (md_open): Initialize ctx with wipememory2 instead
of memset.
--

GCC 11 gives warning on use of memset:
 warning: '__builtin_memset' offset [0, 19] is out of the bounds [0, 0] [-Warray-bounds]

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cipher/md.c b/cipher/md.c
index 428959b2..64dc235a 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -493,7 +493,7 @@ md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
       hd->bufpos = 0;
 
       /* Initialize the private data. */
-      memset (ctx, 0, sizeof *ctx);
+      wipememory2 (ctx, 0, sizeof *ctx);
       ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
       ctx->actual_handle_size = n + sizeof (struct gcry_md_context);
       ctx->flags.secure = secure;
-- 
2.32.0




More information about the Gcrypt-devel mailing list