Updated per PR comments.

This commit is contained in:
Uriah Pollock
2022-10-07 15:08:11 -05:00
parent 9117f8b51b
commit 5cbb099dc9
5 changed files with 60 additions and 47 deletions
+10 -8
View File
@@ -1072,22 +1072,24 @@ WOLFSSL_OCSP_CERTID* wolfSSL_d2i_OCSP_CERTID(WOLFSSL_OCSP_CERTID** cidOut,
const unsigned char** derIn,
int length)
{
if ((derIn == NULL) || (length == 0))
if ((cidOut == NULL) || (derIn == NULL) || (length == 0))
return (NULL);
if (*cidOut != NULL) {
XMEMCPY ((*cidOut)->rawCertId, *derIn, length);
(*cidOut)->rawCertIdSize = length;
}
else {
/* If a NULL is passed we allocate the memory for the caller. */
if (*cidOut == NULL) {
*cidOut = (WOLFSSL_OCSP_CERTID*)XMALLOC(length, NULL, DYNAMIC_TYPE_OPENSSL);
if (*cidOut == NULL) {
return (NULL);
}
XMEMCPY ((*cidOut)->rawCertId, *derIn, length);
(*cidOut)->rawCertIdSize = length;
}
XMEMCPY ((*cidOut)->rawCertId, *derIn, length);
(*cidOut)->rawCertIdSize = length;
/* Per spec. advance past the data that is being returned to the caller. */
*derIn = *derIn + length;
return (*cidOut);
}