Skip to content

Commit 1226ded

Browse files
committed
Check that we don't run out of space for the RID structure
1 parent 71bd9e2 commit 1226ded

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tests/api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18313,6 +18313,8 @@ static int test_wc_PKCS7_GetEnvelopedDataKariRid(void)
1831318313
#if defined(HAVE_PKCS7)
1831418314
#if defined(HAVE_ECC) && (!defined(NO_AES) || (!defined(NO_SHA) || \
1831518315
!defined(NO_SHA256) || defined(WOLFSSL_SHA512)))
18316+
/* The kari-keyid-cms.msg generated by openssl has a 68 byte RID structure.
18317+
* Reserve a bit more than that in case it might grow. */
1831618318
byte rid[256];
1831718319
byte cms[1024];
1831818320
XFILE cmsFile = XBADFILE;
@@ -18342,6 +18344,7 @@ static int test_wc_PKCS7_GetEnvelopedDataKariRid(void)
1834218344
ret = wc_PKCS7_GetEnvelopedDataKariRid(cms, cmsSz, rid, &ridSz);
1834318345
}
1834418346
ExpectIntEQ(ret, 0);
18347+
ExpectIntLT(ridSz, sizeof(rid));
1834518348
ExpectIntGT(ridSz, ridKeyIdentifierOffset);
1834618349
/* The Subject Key Identifier hex file should have 2 hex characters for each
1834718350
* byte of the key identifier in the returned recipient ID (rid), plus a

0 commit comments

Comments
 (0)