Improve allocation bounds in testing

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman 2023-02-20 14:46:51 +00:00
parent a1b2bfff46
commit 716163e824

View file

@ -125,8 +125,8 @@ void pkcs7_verify(char *pkcs7_file,
TEST_ASSERT(file != NULL);
datalen = st.st_size;
/* Add 1 so that data is non-NULL for zero length input */
ASSERT_ALLOC(data, datalen + 1);
/* Special-case for zero-length input so that data will be non-NULL */
ASSERT_ALLOC(data, datalen == 0 ? 1 : datalen);
buflen = fread((void *) data, sizeof(unsigned char), datalen, file);
TEST_EQUAL(buflen, datalen);