aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-30 22:35:01 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-30 22:35:01 +0200
commitb5b3db6c90dbe18c843910ccde1e3481600464c2 (patch)
treeb6566b60025e0ef5e5cd01ea9caf73c027f6dd3f /src/pki.c
parente5a39a3ae993fda41aa81af9f7a3a10e48b8635b (diff)
downloadlibssh-b5b3db6c90dbe18c843910ccde1e3481600464c2.tar.gz
libssh-b5b3db6c90dbe18c843910ccde1e3481600464c2.tar.xz
libssh-b5b3db6c90dbe18c843910ccde1e3481600464c2.zip
pki: Check the type of the key blob earlier.
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c11
1 files 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: