1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-14 08:13:25 +02:00

scd:p15: Accept P15 cards with a zero-length label.

* scd/app-p15.c (read_ef_tokeninfo): Allow for a zero length label.
--

Some versions of the CardOS personalisation software seem to store a
missing labels as zero-length object instead of not storing the object
at all.

Due to a lack of such a card this patch has not been tested.
This commit is contained in:
Werner Koch 2025-04-24 11:20:22 +02:00
parent 97583cf81a
commit db25aa9887
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -3606,14 +3606,23 @@ read_ef_tokeninfo (app_t app)
/* Get next TLV. */ /* Get next TLV. */
err = parse_ber_header (&p, &n, &class, &tag, &constructed, err = parse_ber_header (&p, &n, &class, &tag, &constructed,
&ndef, &objlen, &hdrlen); &ndef, &objlen, &hdrlen);
if (!err && (objlen > n || !objlen)) if (!err && objlen > n)
err = gpg_error (GPG_ERR_INV_OBJ); err = gpg_error (GPG_ERR_INV_OBJ);
if (err) if (err)
goto leave; goto leave;
if (class == CLASS_CONTEXT && tag == 0 && !objlen)
; /* The optional label is stored as zero length object - okay. */
else if (!objlen)
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto leave;
}
} }
if (class == CLASS_CONTEXT && tag == 0) if (class == CLASS_CONTEXT && tag == 0)
{ {
app->app_local->token_label = percent_data_escape (0, NULL, p, objlen); if (objlen)
app->app_local->token_label = percent_data_escape (0, NULL, p, objlen);
p += objlen; p += objlen;
n -= objlen; n -= objlen;