diff options
Diffstat (limited to 'scard-opensc.c')
-rw-r--r-- | scard-opensc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scard-opensc.c b/scard-opensc.c index dd2c28df2..4751ea295 100644 --- a/scard-opensc.c +++ b/scard-opensc.c | |||
@@ -26,9 +26,13 @@ | |||
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | #if defined(SMARTCARD) && defined(USE_OPENSC) | 27 | #if defined(SMARTCARD) && defined(USE_OPENSC) |
28 | 28 | ||
29 | #include <sys/types.h> | ||
30 | |||
29 | #include <openssl/evp.h> | 31 | #include <openssl/evp.h> |
30 | #include <openssl/x509.h> | 32 | #include <openssl/x509.h> |
31 | 33 | ||
34 | #include <stdarg.h> | ||
35 | |||
32 | #include <opensc/opensc.h> | 36 | #include <opensc/opensc.h> |
33 | #include <opensc/pkcs15.h> | 37 | #include <opensc/pkcs15.h> |
34 | 38 | ||
@@ -455,7 +459,9 @@ sc_get_keys(const char *id, const char *pin) | |||
455 | } | 459 | } |
456 | key_count = r; | 460 | key_count = r; |
457 | } | 461 | } |
458 | keys = xmalloc(sizeof(Key *) * (key_count*2+1)); | 462 | if (key_count > 1024) |
463 | fatal("Too many keys (%u), expected <= 1024", key_count); | ||
464 | keys = xcalloc(key_count * 2 + 1, sizeof(Key *)); | ||
459 | for (i = 0; i < key_count; i++) { | 465 | for (i = 0; i < key_count; i++) { |
460 | sc_pkcs15_object_t *tmp_obj = NULL; | 466 | sc_pkcs15_object_t *tmp_obj = NULL; |
461 | cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id; | 467 | cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id; |