Fix 'variable may be used uninitialized' warning for CTR mode
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Wed, 7 Nov 2018 17:12:29 +0000 (19:12 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Wed, 7 Nov 2018 17:12:29 +0000 (19:12 +0200)
* cipher/cipher-ctr.c (_gcry_cipher_ctr_encrypt): Set N to BLOCKSIZE
before counter loop.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/cipher-ctr.c

index 2df0b8c..546d4f8 100644 (file)
@@ -77,6 +77,7 @@ _gcry_cipher_ctr_encrypt (gcry_cipher_hd_t c,
     {
       unsigned char tmp[MAX_BLOCKSIZE];
 
     {
       unsigned char tmp[MAX_BLOCKSIZE];
 
+      n = blocksize;
       do
         {
           nburn = enc_fn (&c->context.c, tmp, c->u_ctr.ctr);
       do
         {
           nburn = enc_fn (&c->context.c, tmp, c->u_ctr.ctr);
@@ -91,7 +92,6 @@ _gcry_cipher_ctr_encrypt (gcry_cipher_hd_t c,
 
           if (inbuflen < blocksize)
             break;
 
           if (inbuflen < blocksize)
             break;
-          n = blocksize;
           cipher_block_xor(outbuf, inbuf, tmp, blocksize);
 
           inbuflen -= n;
           cipher_block_xor(outbuf, inbuf, tmp, blocksize);
 
           inbuflen -= n;