fix for sanity check of null input

This commit is contained in:
JacobBarthelmeh
2024-09-09 09:54:52 -06:00
parent ca3b1a1412
commit 5adad7d869

View File

@@ -3451,7 +3451,16 @@ int wc_PKCS7_SetCustomSKID(PKCS7* pkcs7, byte* in, word16 inSz)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
pkcs7->customSKID = (byte*)XMALLOC(inSz, pkcs7->heap, DYNAMIC_TYPE_PKCS7); if (in == NULL) {
if (pkcs7->customSKID != NULL) {
XFREE(pkcs7->customSKID, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
}
pkcs7->customSKIDSz = 0;
pkcs7->customSKID = NULL;
}
else {
pkcs7->customSKID = (byte*)XMALLOC(inSz, pkcs7->heap,
DYNAMIC_TYPE_PKCS7);
if (pkcs7->customSKID == NULL) { if (pkcs7->customSKID == NULL) {
ret = MEMORY_E; ret = MEMORY_E;
} }
@@ -3459,6 +3468,8 @@ int wc_PKCS7_SetCustomSKID(PKCS7* pkcs7, byte* in, word16 inSz)
XMEMCPY(pkcs7->customSKID, in, inSz); XMEMCPY(pkcs7->customSKID, in, inSz);
pkcs7->customSKIDSz = inSz; pkcs7->customSKIDSz = inSz;
} }
}
return ret; return ret;
} }