Compare commits

...

2 Commits

Author SHA1 Message Date
Conor Patrick
eac22367db limit possible recursions in tinycbor 2020-02-27 15:28:01 -05:00
Conor Patrick
47a2b131e9 more strict checks in cbor parsing 2020-02-27 15:27:23 -05:00
2 changed files with 14 additions and 3 deletions

View File

@ -666,8 +666,8 @@ uint8_t ctap_parse_extensions(CborValue * val, CTAP_extensions * ext)
if (ret == CborErrorOutOfMemory) if (ret == CborErrorOutOfMemory)
{ {
printf2(TAG_ERR,"Error, rp map key is too large. Ignoring.\n"); printf2(TAG_ERR,"Error, rp map key is too large. Ignoring.\n");
cbor_value_advance(&map); check_ret( cbor_value_advance(&map) );
cbor_value_advance(&map); check_ret( cbor_value_advance(&map) );
continue; continue;
} }
check_ret(ret); check_ret(ret);
@ -1353,11 +1353,21 @@ uint8_t ctap_parse_client_pin(CTAP_clientPin * CP, uint8_t * request, int length
break; break;
case CP_getKeyAgreement: case CP_getKeyAgreement:
printf1(TAG_CP,"CP_getKeyAgreement\n"); printf1(TAG_CP,"CP_getKeyAgreement\n");
if (cbor_value_get_type(&map) != CborBooleanType)
{
printf2(TAG_ERR,"Error, expecting cbor boolean\n");
return CTAP2_ERR_INVALID_CBOR_TYPE;
}
ret = cbor_value_get_boolean(&map, &CP->getKeyAgreement); ret = cbor_value_get_boolean(&map, &CP->getKeyAgreement);
check_ret(ret); check_ret(ret);
break; break;
case CP_getRetries: case CP_getRetries:
printf1(TAG_CP,"CP_getRetries\n"); printf1(TAG_CP,"CP_getRetries\n");
if (cbor_value_get_type(&map) != CborBooleanType)
{
printf2(TAG_ERR,"Error, expecting cbor boolean\n");
return CTAP2_ERR_INVALID_CBOR_TYPE;
}
ret = cbor_value_get_boolean(&map, &CP->getRetries); ret = cbor_value_get_boolean(&map, &CP->getRetries);
check_ret(ret); check_ret(ret);
break; break;

View File

@ -84,4 +84,5 @@ cbor:
cd ../../tinycbor/ && make clean cd ../../tinycbor/ && make clean
cd ../../tinycbor/ && make CC="$(CC)" AR=$(AR) \ cd ../../tinycbor/ && make CC="$(CC)" AR=$(AR) \
LDFLAGS="$(LDFLAGS_LIB)" \ LDFLAGS="$(LDFLAGS_LIB)" \
CFLAGS="$(CFLAGS) -Os" CFLAGS="$(CFLAGS) -Os -DCBOR_PARSER_MAX_RECURSIONS=3"