Skip to content

Commit

Permalink
Merge pull request #4069 from guidovranken/zd12349
Browse files Browse the repository at this point in the history
Several ASN decoder fixes
  • Loading branch information
ejohnstown committed May 26, 2021
2 parents 41af3da + 1fbc3dc commit 1fe4453
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wolfcrypt/src/asn.c
Expand Up @@ -17211,12 +17211,16 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
ret = GetOctetString(source, &idx, &length, size);
if (ret < 0)
return ret;
if (length > (int)sizeof(single->issuerHash))
return BUFFER_E;
XMEMCPY(single->issuerHash, source + idx, length);
idx += length;
/* Save reference to the hash of the issuer public key */
ret = GetOctetString(source, &idx, &length, size);
if (ret < 0)
return ret;
if (length > (int)sizeof(single->issuerKeyHash))
return BUFFER_E;
XMEMCPY(single->issuerKeyHash, source + idx, length);
idx += length;

Expand Down Expand Up @@ -17470,6 +17474,9 @@ static int DecodeResponseData(byte* source,
}
single = single->next;
XMEMSET(single, 0, sizeof(OcspEntry));
single->status = (CertStatus*)XMALLOC(sizeof(CertStatus),
resp->heap, DYNAMIC_TYPE_OCSP_STATUS);
XMEMSET(single->status, 0, sizeof(CertStatus));

This comment has been minimized.

Copy link
@bernd-edlinger

bernd-edlinger May 27, 2021

Should'nt the return value of XMALLOC be checked here to be non-zero?

single->isDynamic = 1;
}
}
Expand Down Expand Up @@ -17666,8 +17673,10 @@ void FreeOcspResponse(OcspResponse* resp)
OcspEntry *single, *next;
for (single = resp->single; single; single = next) {
next = single->next;
if (single->isDynamic)
if (single->isDynamic) {
XFREE(single->status, resp->heap, DYNAMIC_TYPE_OCSP_STATUS);
XFREE(single, resp->heap, DYNAMIC_TYPE_OCSP_ENTRY);
}
}
}

Expand Down

0 comments on commit 1fe4453

Please sign in to comment.