diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-08-30 22:35:01 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-30 22:35:01 +0200 |
commit | b5b3db6c90dbe18c843910ccde1e3481600464c2 (patch) | |
tree | b6566b60025e0ef5e5cd01ea9caf73c027f6dd3f /src/pki.c | |
parent | e5a39a3ae993fda41aa81af9f7a3a10e48b8635b (diff) | |
download | libssh-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.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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: |