From c5c067fd128c3a284c0ad6a3d39c7345a9a6bd0d Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Tue, 4 Sep 2012 15:44:32 +0200 Subject: [PATCH] ocb_init fix (preventing index overflow) --- src/encauth/ocb/ocb_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/encauth/ocb/ocb_init.c b/src/encauth/ocb/ocb_init.c index 604ae0e..22b2f46 100644 --- a/src/encauth/ocb/ocb_init.c +++ b/src/encauth/ocb/ocb_init.c @@ -60,11 +60,15 @@ int ocb_init(ocb_state *ocb, int cipher, /* determine which polys to use */ ocb->block_len = cipher_descriptor[cipher].block_length; - for (poly = 0; poly < (int)(sizeof(polys)/sizeof(polys[0])); poly++) { + x = (int)(sizeof(polys)/sizeof(polys[0])); + for (poly = 0; poly < x; poly++) { if (polys[poly].len == ocb->block_len) { break; } } + if (poly == x) { + return CRYPT_INVALID_ARG; /* block_len not found in polys */ + } if (polys[poly].len != ocb->block_len) { return CRYPT_INVALID_ARG; }