libopensc: check data returned by 'read-public-key'
fix error message
This commit is contained in:
parent
da5934a6ff
commit
f7771c9b08
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue