Skip to content

Commit 686ab1d

Browse files
committed
Validate CRL entry-extension OID encoding before decoding
1 parent 73f1a7b commit 686ab1d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36869,6 +36869,19 @@ static int ParseCRL_EntryExtensions(const byte* buff, word32 idx, word32 maxIdx,
3686936869
if (GetOctetString(buff, &valIdx, &valLen, end) < 0) {
3687036870
return ASN_PARSE_E;
3687136871
}
36872+
/* Validate the OID encoding before decoding it. GetLength()
36873+
* returns 0 (not an error) for a zero-length item, and an OID
36874+
* whose last content octet has bit 8 set encodes no complete
36875+
* sub-identifier. In either case DecodeObjectId() returns 0
36876+
* with *outSz == 0, having written nothing to decOid, which
36877+
* would hand the callback an uninitialized OID buffer. */
36878+
if (GetASN_ObjectId(buff, oidContent, oidLen) != 0) {
36879+
return ASN_PARSE_E;
36880+
}
36881+
/* Redundant given the check above, but it makes "the callback
36882+
* never sees uninitialized stack" true by construction rather
36883+
* than by reasoning about DecodeObjectId's internals. */
36884+
XMEMSET(decOid, 0, sizeof(decOid));
3687236885
cbRet = DecodeObjectId(buff + oidContent, (word32)oidLen,
3687336886
decOid, &decOidSz);
3687436887
if (cbRet == 0 && dcrl->unknownExtCallback != NULL) {

0 commit comments

Comments
 (0)