X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/540d72c3b0c580a78191cf0b5123c07e9e95d3b4..7267e80717a7c9787e70004b902dddc35659d3c8:/openssh/scard-opensc.c diff --git a/openssh/scard-opensc.c b/openssh/scard-opensc.c index a9b7ebc..36dae05 100644 --- a/openssh/scard-opensc.c +++ b/openssh/scard-opensc.c @@ -26,16 +26,21 @@ #include "includes.h" #if defined(SMARTCARD) && defined(USE_OPENSC) +#include + #include #include +#include +#include + #include #include #include "key.h" #include "log.h" #include "xmalloc.h" -#include "readpass.h" +#include "misc.h" #include "scard.h" #if OPENSSL_VERSION_NUMBER < 0x00907000L && defined(CRYPTO_LOCK_ENGINE) @@ -455,7 +460,9 @@ sc_get_keys(const char *id, const char *pin) } key_count = r; } - keys = xmalloc(sizeof(Key *) * (key_count*2+1)); + if (key_count > 1024) + fatal("Too many keys (%u), expected <= 1024", key_count); + keys = xcalloc(key_count * 2 + 1, sizeof(Key *)); for (i = 0; i < key_count; i++) { sc_pkcs15_object_t *tmp_obj = NULL; cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id;