From b5b3db6c90dbe18c843910ccde1e3481600464c2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 30 Aug 2011 22:35:01 +0200 Subject: [PATCH] pki: Check the type of the key blob earlier. --- src/pki.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pki.c b/src/pki.c index a0c2d35a..0774f90e 100644 --- a/src/pki.c +++ b/src/pki.c @@ -655,6 +655,7 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob, ssh_buffer buffer; ssh_string type_s = NULL; char *type_c = NULL; + enum ssh_keytypes_e type; int rc; if (key_blob == NULL || pkey == NULL) { @@ -687,10 +688,16 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob, } ssh_string_free(type_s); - rc = pki_import_pubkey_buffer(buffer, ssh_key_type_from_name(type_c), pkey); + type = ssh_key_type_from_name(type_c); + free(type_c); + if (type == SSH_KEYTYPE_UNKNOWN) { + ssh_pki_log("Unknown key type found!"); + goto fail; + } + + rc = pki_import_pubkey_buffer(buffer, type, pkey); ssh_buffer_free(buffer); - free(type_c); return rc; fail: