[PATCH] gostr3411-94: fix the iteration count for length filling loop

Dmitry Eremin-Solenikov dbaryshkov at gmail.com
Sun Dec 28 10:05:43 CET 2014


The maximum iteration count for filling the l (bit length) array was
incrrectly set to 32 (missed that in u8->u32 refactoring). This was not
resulting in stack corruption, since nblocks variable would be exausted
earlier compared to 8 32-bit values (the size of the array).

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
 cipher/gostr3411-94.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c
index 91e5b4c..7b16e61 100644
--- a/cipher/gostr3411-94.c
+++ b/cipher/gostr3411-94.c
@@ -307,7 +307,7 @@ gost3411_final (void *context)
   l[0] |= nblocks << 8;
   nblocks >>= 24;
 
-  for (i = 1; i < 32 && nblocks != 0; i++)
+  for (i = 1; i < 8 && nblocks != 0; i++)
     {
       l[i] = nblocks;
       nblocks >>= 24;
-- 
2.1.4




More information about the Gcrypt-devel mailing list