summaryrefslogtreecommitdiffstats
path: root/test/bio_enc_test.c
diff options
context:
space:
mode:
authorPeiwei Hu <jlu.hpw@foxmail.com>2021-12-06 17:33:42 +0800
committerPauli <pauli@openssl.org>2021-12-08 15:11:57 +1100
commit24dd9fc4c6c8341cd7f81d5e31513e59fcb934cf (patch)
tree156e5bbfddc0a83569bc9a634567b4be64a4522a /test/bio_enc_test.c
parentba16c6cb1d0ceb78a54c667a15a64d28a15462d3 (diff)
bio_enc.c: add memory allocation check
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17206) (cherry picked from commit 684326d3bd3131debcdc410790e8dcf16f96103f)
Diffstat (limited to 'test/bio_enc_test.c')
-rw-r--r--test/bio_enc_test.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/bio_enc_test.c b/test/bio_enc_test.c
index aeca062f3f..ec02628f84 100644
--- a/test/bio_enc_test.c
+++ b/test/bio_enc_test.c
@@ -51,6 +51,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
/* reference output for single-chunk operation */
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT)))
return 0;
BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE));
@@ -60,6 +62,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
/* perform split operations and compare to reference */
for (i = 1; i < lref; i++) {
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT))) {
TEST_info("Split encrypt failed @ operation %d", i);
return 0;
@@ -87,6 +91,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
int delta;
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT))) {
TEST_info("Small chunk encrypt failed @ operation %d", i);
return 0;
@@ -108,6 +114,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
/* reference output for single-chunk operation */
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, DECRYPT)))
return 0;
/* Use original reference output as input */
@@ -123,6 +131,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
/* perform split operations and compare to reference */
for (i = 1; i < lref; i++) {
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, DECRYPT))) {
TEST_info("Split decrypt failed @ operation %d", i);
return 0;
@@ -150,6 +160,8 @@ static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
int delta;
b = BIO_new(BIO_f_cipher());
+ if (!TEST_ptr(b))
+ return 0;
if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, DECRYPT))) {
TEST_info("Small chunk decrypt failed @ operation %d", i);
return 0;