[PATCH 5/5] [tests] increase size of some buffers that were being overflowed

Shawn Landden shawn at git.icu
Tue Jul 9 16:58:12 CEST 2019


with this everything is valgrind-clean

2019-07-09  Shawn Landden  <shawn at git.icu>
	* cipher/mac-poly1305.c: Increase size of overflowed buffers.
	* tests/basic.c: Increase size of overflowed buffers.

Signed-off-by: Shawn Landden <shawn at git.icu>
---
 cipher/mac-poly1305.c | 2 +-
 tests/basic.c         | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cipher/mac-poly1305.c b/cipher/mac-poly1305.c
index b80f87db..612a48f4 100644
--- a/cipher/mac-poly1305.c
+++ b/cipher/mac-poly1305.c
@@ -51,11 +51,11 @@ poly1305mac_open (gcry_mac_hd_t h)
   int cipher_algo;
 
   if (secure)
     mac_ctx = xtrycalloc_secure (1, sizeof(*mac_ctx));
   else
-    mac_ctx = xtrycalloc (1, sizeof(*mac_ctx));
+    mac_ctx = xtrycalloc (1, sizeof(*mac_ctx)*2);
 
   if (!mac_ctx)
     return gpg_err_code_from_syserror ();
 
   h->u.poly1305mac.ctx = mac_ctx;
diff --git a/tests/basic.c b/tests/basic.c
index b798eaaf..7454bce5 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -8460,13 +8460,13 @@ check_one_cipher_core (int algo, int mode, int flags,
   unsigned int blklen;
   unsigned int piecelen;
   unsigned int pos;
   unsigned int taglen;
 
-  in_buffer = malloc (nplain + 1);
-  out_buffer = malloc (nplain + 1);
-  enc_result = malloc (nplain);
+  in_buffer = malloc (nplain + 17);
+  out_buffer = malloc (nplain + 17);
+  enc_result = malloc (nplain + 17);
   if (!in_buffer || !out_buffer || !enc_result)
     {
       fail ("pass %d, algo %d, mode %d, malloc failed\n",
 	    pass, algo, mode);
       goto err_out_free;
-- 
2.20.1




More information about the Gcrypt-devel mailing list