Skip to content

Commit c619c19

Browse files
committed
asn: add underflow check to idx.
1 parent 05bc7e0 commit c619c19

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41543,11 +41543,11 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
4154341543
int nid;
4154441544
#endif
4154541545
const char* ln = NULL;
41546-
word32 i = 0;
41546+
word32 idx = 0;
4154741547
int known = 1;
4154841548

4154941549
/* Get the OID value for the OBJECT_ID. */
41550-
if (GetObjectId(asn1->data + asn1->offset, &i, &oid, oidIgnoreType,
41550+
if (GetObjectId(asn1->data + asn1->offset, &idx, &oid, oidIgnoreType,
4155141551
asn1->item.len + 2) == WC_NO_ERR_TRACE(ASN_PARSE_E)) {
4155241552
known = 0;
4155341553
}
@@ -41563,9 +41563,9 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
4156341563
/* Lookup long name for extra known OID values. */
4156441564
if (Oid2LongName(oid, &ln) != 0) {
4156541565
}
41566-
else if ((asn1->nameCb != NULL) &&
41566+
else if ((asn1->nameCb != NULL) && (idx >= 2) &&
4156741567
((ln = asn1->nameCb(asn1->data + asn1->offset + 2,
41568-
i - 2))) != NULL) {
41568+
idx - 2))) != NULL) {
4156941569
}
4157041570
else {
4157141571
/* Unknown OID value. */

0 commit comments

Comments
 (0)