libopensc: OID with only zeros in array do not valid

This commit is contained in:
Viktor Tarasov 2012-09-23 21:02:31 +02:00
parent 760cd1cfbd
commit d525ca97e3
2 changed files with 9 additions and 0 deletions

View File

@ -231,6 +231,8 @@ int sc_pkcs15_parse_tokeninfo(sc_context_t *ctx,
if (ti->preferred_language == NULL)
return SC_ERROR_OUT_OF_MEMORY;
}
sc_init_oid(&ti->profile_indication.oid);
if (asn1_toki_attrs[13].flags & SC_ASN1_PRESENT) {
if (asn1_profile_indication[0].flags & SC_ASN1_PRESENT) {
sc_log(ctx, "ProfileIndication.oid present");

View File

@ -208,12 +208,19 @@ int sc_compare_oid(const struct sc_object_id *oid1, const struct sc_object_id *o
int sc_valid_oid(const struct sc_object_id *oid)
{
int ii;
if (!oid)
return 0;
if (oid->value[0] == -1 || oid->value[1] == -1)
return 0;
if (oid->value[0] > 2 || oid->value[1] > 39)
return 0;
for (ii=0;ii<SC_MAX_OBJECT_ID_OCTETS;ii++)
if (oid->value[ii])
break;
if (ii==SC_MAX_OBJECT_ID_OCTETS)
return 0;
return 1;
}