diff options
author | Werner Koch <[email protected]> | 2025-04-24 09:20:22 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-04-24 09:23:08 +0000 |
commit | db25aa98873d8a2e68dedda53bd867be8a014987 (patch) | |
tree | e02713ae6f620d8ff467cbf621f6730e50bffed1 | |
parent | gpgscm: Fix initialization for fixed size chars. (diff) | |
download | gnupg-db25aa98873d8a2e68dedda53bd867be8a014987.tar.gz gnupg-db25aa98873d8a2e68dedda53bd867be8a014987.zip |
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.
-rw-r--r-- | scd/app-p15.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scd/app-p15.c b/scd/app-p15.c index 1eeae59af..f5c5f7a17 100644 --- a/scd/app-p15.c +++ b/scd/app-p15.c @@ -3606,14 +3606,23 @@ read_ef_tokeninfo (app_t app) /* Get next TLV. */ err = parse_ber_header (&p, &n, &class, &tag, &constructed, &ndef, &objlen, &hdrlen); - if (!err && (objlen > n || !objlen)) + if (!err && objlen > n) err = gpg_error (GPG_ERR_INV_OBJ); if (err) 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) { - 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; n -= objlen; |