]> git.codecow.com Git - Monocypher.git/commitdiff
Fixed buffer overflow (wipe too big)
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 28 Jan 2018 22:51:43 +0000 (23:51 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 28 Jan 2018 22:51:43 +0000 (23:51 +0100)
src/monocypher.c

index 1f2fcd8a4a5a90ded322d890fc01f9206bf1558f..8e0b27ba325ae8a6bc4e7221a00f74832eb288e8 100644 (file)
@@ -1791,11 +1791,11 @@ int crypto_aead_unlock(u8       *plain_text,
     crypto_lock_auth(&ctx, cipher_text, text_size);
     crypto_chacha_ctx chacha_ctx = ctx.chacha; // avoid the wiping...
     if (crypto_unlock_final(&ctx, mac)) {      // ...that occurs here
-        crypto_wipe(&chacha_ctx, sizeof(ctx));
+        crypto_wipe(&chacha_ctx, sizeof(chacha_ctx));
         return -1; // reject forgeries before wasting our time decrypting
     }
     crypto_chacha20_encrypt(&chacha_ctx, plain_text, cipher_text, text_size);
-    crypto_wipe(&chacha_ctx, sizeof(ctx));
+    crypto_wipe(&chacha_ctx, sizeof(chacha_ctx));
     return 0;
 }