1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

pki: Add a size limit for pubkey files.

This commit is contained in:
Andreas Schneider
2012-11-21 12:44:00 +01:00
parent 571dc42335
commit e403596d98
2 changed files with 3 additions and 1 deletions

View File

@@ -31,6 +31,8 @@
#include "libssh/crypto.h" #include "libssh/crypto.h"
#define MAX_PUBKEY_SIZE 0x100000 /* 1M */
#define SSH_KEY_FLAG_EMPTY 0x0 #define SSH_KEY_FLAG_EMPTY 0x0
#define SSH_KEY_FLAG_PUBLIC 0x0001 #define SSH_KEY_FLAG_PUBLIC 0x0001
#define SSH_KEY_FLAG_PRIVATE 0x0002 #define SSH_KEY_FLAG_PRIVATE 0x0002

View File

@@ -816,7 +816,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
return SSH_ERROR; return SSH_ERROR;
} }
if (sb.st_size + 1 < sb.st_size) { if (sb.st_size > MAX_PUBKEY_SIZE) {
return SSH_ERROR; return SSH_ERROR;
} }