diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-11-21 12:44:00 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-11-21 12:44:00 +0100 |
commit | e403596d98b056fa496f1fd5e18a66a416a17e8a (patch) | |
tree | b7203fb9d539355ed2a2c16ee8893733a0f685cf | |
parent | 571dc4233530e47fd2300b0fe42ddf6b830ded37 (diff) | |
download | libssh-e403596d98b056fa496f1fd5e18a66a416a17e8a.tar.gz libssh-e403596d98b056fa496f1fd5e18a66a416a17e8a.tar.xz libssh-e403596d98b056fa496f1fd5e18a66a416a17e8a.zip |
pki: Add a size limit for pubkey files.
-rw-r--r-- | include/libssh/pki.h | 2 | ||||
-rw-r--r-- | src/pki.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/include/libssh/pki.h b/include/libssh/pki.h index b9da5fb..881472d 100644 --- a/include/libssh/pki.h +++ b/include/libssh/pki.h @@ -31,6 +31,8 @@ #include "libssh/crypto.h" +#define MAX_PUBKEY_SIZE 0x100000 /* 1M */ + #define SSH_KEY_FLAG_EMPTY 0x0 #define SSH_KEY_FLAG_PUBLIC 0x0001 #define SSH_KEY_FLAG_PRIVATE 0x0002 @@ -816,7 +816,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey) return SSH_ERROR; } - if (sb.st_size + 1 < sb.st_size) { + if (sb.st_size > MAX_PUBKEY_SIZE) { return SSH_ERROR; } |