@@ -34374,17 +34374,19 @@ static int test_zd21414_pkcs7_ori_oid_overflow(void)
3437434374 0x4D,0x80,0x10,0xBD,0x36,0x26,0xF5,0x6E,0x11,0xD0,0xBB,0x5C,
3437534375 0x15,0x19,0xA7,0x6B,0xC2,0xC2,0xB6
3437634376 }; /* 187 bytes */
34377- PKCS7 pkcs7;
34377+ PKCS7* pkcs7 = NULL ;
3437834378 byte decoded[256];
3437934379
34380- ExpectIntEQ(wc_PKCS7_Init(&pkcs7, NULL, INVALID_DEVID), 0);
34381- /* ORI decrypt callback must be set or parser skips ORI processing */
34382- wc_PKCS7_SetOriDecryptCb(&pkcs7, oriDecryptCb_zd21414);
34383- /* Without fix: overflows oriOID[32] → crash.
34384- * With fix: returns BUFFER_E before the copy. */
34385- ExpectIntLT(wc_PKCS7_DecodeEnvelopedData(&pkcs7, (byte*)malformed,
34386- (word32)sizeof(malformed), decoded, sizeof(decoded)), 0);
34387- wc_PKCS7_Free(&pkcs7);
34380+ ExpectNotNull(pkcs7 = wc_PKCS7_New(NULL, INVALID_DEVID));
34381+ if (pkcs7 != NULL) {
34382+ /* ORI decrypt callback must be set or parser skips ORI processing */
34383+ wc_PKCS7_SetOriDecryptCb(pkcs7, oriDecryptCb_zd21414);
34384+ /* Without fix: overflows oriOID[32] → crash.
34385+ * With fix: returns BUFFER_E before the copy. */
34386+ ExpectIntLT(wc_PKCS7_DecodeEnvelopedData(pkcs7, (byte*)malformed,
34387+ (word32)sizeof(malformed), decoded, sizeof(decoded)), 0);
34388+ wc_PKCS7_Free(pkcs7);
34389+ }
3438834390#endif
3438934391 return EXPECT_RESULT();
3439034392}
0 commit comments