libdmsg - add safeties
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Feb 2015 05:03:06 +0000 (21:03 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 28 Feb 2015 05:03:06 +0000 (21:03 -0800)
* Preinitialize return counters to 0 as a safety.  Not required for proper
  operation.

lib/libdmsg/crypto.c

index 88e48e3..55eca1e 100644 (file)
@@ -209,10 +209,12 @@ dmsg_crypto_gcm_encrypt_chunk(dmsg_ioq_t *ioq, char *ct, char *pt,
        if (!ok)
                goto fail;
 
+       u_len = 0;      /* safety */
        ok = EVP_EncryptUpdate(&ioq->ctx, ct, &u_len, pt, in_size);
        if (!ok)
                goto fail;
 
+       f_len = 0;      /* safety */
        ok = EVP_EncryptFinal(&ioq->ctx, ct + u_len, &f_len);
        if (!ok)
                goto fail;