diff options
author | Werner Koch <[email protected]> | 2021-06-16 18:39:00 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-02-17 10:38:57 +0000 |
commit | 88606cc484e4c1342c5e4d8386f161103d163a02 (patch) | |
tree | 8ebcba8dd2c961f7f9a334594fd2043debde4dde | |
parent | gpg: --gen-random code cleanup by using es_set_binary. (diff) | |
download | gnupg-88606cc484e4c1342c5e4d8386f161103d163a02.tar.gz gnupg-88606cc484e4c1342c5e4d8386f161103d163a02.zip |
scd:p15: Handle cards with bad encoded path objects.
* scd/app-p15.c (read_ef_prkdf, read_ef_pukdf)
(read_ef_cdf, read_ef_aodf): Allow for a zero length path and
correctly skip unsupported auth types.
--
Signed-off-by: Werner Koch <[email protected]>
Backported-from-master: 7a8545c91b09277b0833dc0e5881ba5d1c8dbca3
-rw-r--r-- | scd/app-p15.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/scd/app-p15.c b/scd/app-p15.c index 4a855b97d..131cc2cb7 100644 --- a/scd/app-p15.c +++ b/scd/app-p15.c @@ -1919,10 +1919,12 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result) if (err) goto parse_error; - /* Make sure that the next element is a non zero path and of - even length (FID are two bytes each). */ + /* Make sure that the next element has a path of even length + * (FIDs are two bytes each). We should check that the path + * length is non-zero but some cards return a zero length path + * nevertheless (e.g. A.E.T. Europe Java applets). */ if (class != CLASS_UNIVERSAL || tag != TAG_OCTET_STRING - || !objlen || (objlen & 1) ) + || (objlen & 1) ) { errstr = "invalid path reference"; goto parse_error; @@ -2228,10 +2230,10 @@ read_ef_pukdf (app_t app, unsigned short fid, pukdf_object_t *result) if (err) goto parse_error; - /* Make sure that the next element is a non zero path and of - even length (FID are two bytes each). */ + /* Make sure that the next element has a path of even length + * (FIDs are two bytes each). */ if (class != CLASS_UNIVERSAL || tag != TAG_OCTET_STRING - || !objlen || (objlen & 1) ) + || (objlen & 1) ) { errstr = "invalid path reference"; goto parse_error; @@ -2528,10 +2530,10 @@ read_ef_cdf (app_t app, unsigned short fid, int cdftype, cdf_object_t *result) if (err) goto parse_error; - /* Make sure that the next element is a non zero path and of - even length (FID are two bytes each). */ + /* Make sure that the next element has a path of even length + * (FIDs are two bytes each). */ if (class != CLASS_UNIVERSAL || tag != TAG_OCTET_STRING - || !objlen || (objlen & 1) ) + || (objlen & 1) ) { errstr = "invalid path reference"; goto parse_error; @@ -2783,6 +2785,8 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result) case 2: errstr = "external auth type are not supported"; break; default: errstr = "unknown privateKeyObject"; break; } + p += objlen; + n -= objlen; goto parse_error; } else |