diff options
-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 951ca374e..a2f36551d 100644 --- a/scd/app-p15.c +++ b/scd/app-p15.c @@ -3536,14 +3536,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; |