Skip to content

Commit a3b54e9

Browse files
committed
cred: check attestation object for mandatory items
Makes error handling consistent with fido_dev_make_cred_rx().
1 parent daeaad7 commit a3b54e9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/cred.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ fido_cred_set_attobj(fido_cred_t *cred, const unsigned char *ptr, size_t len)
789789
struct cbor_load_result cbor;
790790
int r = FIDO_ERR_INVALID_ARGUMENT;
791791

792-
fido_cred_clean_attobj(cred);
792+
fido_cred_reset_rx(cred);
793793

794794
if (ptr == NULL || len == 0)
795795
goto fail;
@@ -802,12 +802,20 @@ fido_cred_set_attobj(fido_cred_t *cred, const unsigned char *ptr, size_t len)
802802
fido_log_debug("%s: cbor_decode_attobj", __func__);
803803
goto fail;
804804
}
805+
if (cred->fmt == NULL || fido_blob_is_empty(&cred->authdata_cbor) ||
806+
fido_blob_is_empty(&cred->attcred.id)) {
807+
r = FIDO_ERR_INVALID_CBOR;
808+
goto fail;
809+
}
805810

806811
r = FIDO_OK;
807812
fail:
808813
if (item != NULL)
809814
cbor_decref(&item);
810815

816+
if (r != FIDO_OK)
817+
fido_cred_reset_rx(cred);
818+
811819
return (r);
812820
}
813821

src/winhello.c

+8
Original file line numberDiff line numberDiff line change
@@ -1026,10 +1026,18 @@ fido_winhello_make_cred(fido_dev_t *dev, fido_cred_t *cred, const char *pin,
10261026
fido_log_debug("%s: translate_winhello_cred", __func__);
10271027
goto fail;
10281028
}
1029+
if (cred->fmt == NULL || fido_blob_is_empty(&cred->authdata_cbor) ||
1030+
fido_blob_is_empty(&cred->attcred.id)) {
1031+
r = FIDO_ERR_INVALID_CBOR;
1032+
goto fail;
1033+
}
10291034

10301035
r = FIDO_OK;
10311036
fail:
10321037
winhello_cred_free(ctx);
10331038

1039+
if (r != FIDO_OK)
1040+
fido_cred_reset_rx(cred);
1041+
10341042
return r;
10351043
}

0 commit comments

Comments
 (0)