Skip to content

Commit 2d39410

Browse files
authored
Merge pull request #9630 from gasbytes/signedAttribsCount-fix
Increment signedAttribsCount with the right number of attributes it encoded
2 parents 819eab8 + 9c7b586 commit 2d39410

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wolfcrypt/src/pkcs7.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,11 @@ static int wc_PKCS7_BuildSignedAttributes(wc_PKCS7* pkcs7, ESD* esd,
20742074

20752075
/* add custom signed attributes if set */
20762076
if (pkcs7->signedAttribsSz > 0 && pkcs7->signedAttribs != NULL) {
2077+
word32 availableSpace = MAX_SIGNED_ATTRIBS_SZ - atrIdx;
2078+
2079+
if (pkcs7->signedAttribsSz > availableSpace)
2080+
return BUFFER_E;
2081+
20772082
esd->signedAttribsCount += pkcs7->signedAttribsSz;
20782083
esd->signedAttribsSz += (word32)EncodeAttributes(
20792084
&esd->signedAttribs[atrIdx], (int)esd->signedAttribsCount,

0 commit comments

Comments
 (0)