From d77207efdde4dbae2ea1d55b5cc8ade535b988ba Mon Sep 17 00:00:00 2001 From: Harry Ramsey Date: Wed, 13 Nov 2024 09:42:59 +0000 Subject: [PATCH] Fix issue where input data could be length 0 This commit fixes an issue in the GCM shared buffer test case where input data could be of length 0 and an adequate buffer was not allocated. Signed-off-by: Harry Ramsey --- tests/suites/test_suite_gcm.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_gcm.function b/tests/suites/test_suite_gcm.function index e7b024ec74..43c11c3d00 100644 --- a/tests/suites/test_suite_gcm.function +++ b/tests/suites/test_suite_gcm.function @@ -627,7 +627,7 @@ void gcm_encrypt_input_output_buffer_overlap(int cipher_id, data_t *key_str, * Therefore we must ensure we round up to the nearest 128-bits/16-bytes. */ buffer_len = src_str->len; - if (buffer_len % 16 != 0) { + if (buffer_len % 16 != 0 || buffer_len == 0) { buffer_len += (16 - (buffer_len % 16)); } TEST_CALLOC(buffer, buffer_len); @@ -686,7 +686,7 @@ void gcm_decrypt_input_output_buffer_overlap(int cipher_id, data_t *key_str, * Therefore we must ensure we round up to the nearest 128-bits/16-bytes. */ buffer_len = src_str->len; - if (buffer_len % 16 != 0) { + if (buffer_len % 16 != 0 || buffer_len == 0) { buffer_len += (16 - (buffer_len % 16)); } TEST_CALLOC(buffer, buffer_len);