diff --git a/src/libopensc/errors.c b/src/libopensc/errors.c index aee5fa8b..9098b35b 100644 --- a/src/libopensc/errors.c +++ b/src/libopensc/errors.c @@ -90,8 +90,8 @@ const char *sc_strerror(int error) "Required ASN.1 object not found", "Premature end of ASN.1 stream", "Out of memory", + "Too many objects", "Object not valid", - "Object not found", "Requested object not found", "Not supported", "Passphrase required", diff --git a/src/libopensc/pkcs15-pubkey.c b/src/libopensc/pkcs15-pubkey.c index 3c670951..520852ba 100644 --- a/src/libopensc/pkcs15-pubkey.c +++ b/src/libopensc/pkcs15-pubkey.c @@ -685,6 +685,9 @@ sc_pkcs15_read_pubkey(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_obj LOG_TEST_RET(ctx, SC_ERROR_NOT_IMPLEMENTED, "No way to get public key"); } + if (!data || !len) + LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_VALID); + pubkey = calloc(1, sizeof(struct sc_pkcs15_pubkey)); if (pubkey == NULL) { free(data); diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index b23795d2..3459c826 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -788,7 +788,8 @@ static int read_ssh_key(void) r = authenticate(obj); if (r >= 0) r = sc_pkcs15_read_pubkey(p15card, obj, &pubkey); - } else if (r == SC_ERROR_OBJECT_NOT_FOUND) { + } + else if (r == SC_ERROR_OBJECT_NOT_FOUND) { /* No pubkey - try if there's a certificate */ r = sc_pkcs15_find_cert_by_id(p15card, &id, &obj); if (r >= 0) {