Plug leaks due to not resetting the EVP_CIPHER_CTX
authortb <tb@openbsd.org>
Mon, 5 Sep 2022 21:34:23 +0000 (21:34 +0000)
committertb <tb@openbsd.org>
Mon, 5 Sep 2022 21:34:23 +0000 (21:34 +0000)
regress/lib/libcrypto/rc4/rc4_test.c

index 6c93834..f575060 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rc4_test.c,v 1.1 2022/09/03 17:43:14 tb Exp $ */
+/*     $OpenBSD: rc4_test.c,v 1.2 2022/09/05 21:34:23 tb Exp $ */
 /*
  * Copyright (c) 2022 Joshua Sing <joshua@hypera.dev>
  *
@@ -395,6 +395,11 @@ rc4_test(void)
                        goto failed;
                }
 
+               if (!EVP_CIPHER_CTX_reset(ctx)) {
+                       fprintf(stderr, "FAIL: EVP_CIPHER_CTX_reset failed\n");
+                       goto failed;
+               }
+
                if (memcmp(rt->out, out, rt->len) != 0) {
                        fprintf(stderr, "FAIL: EVP encryption mismatch\n");
                        goto failed;
@@ -427,6 +432,11 @@ rc4_test(void)
                        goto failed;
                }
 
+               if (!EVP_CIPHER_CTX_reset(ctx)) {
+                       fprintf(stderr, "FAIL: EVP_CIPHER_CTX_reset failed\n");
+                       goto failed;
+               }
+
                if (memcmp(rt->out, out, rt->len) != 0) {
                        fprintf(stderr, "FAIL: EVP decryption mismatch\n");
                        goto failed;