Merge pull request #616 from mtrojnar/buffer_overflow

Heap-based buffer overflow fix in mutex_create() with PKCS11_THREAD_LOCKING and HAVE_PTHREAD defined
This commit is contained in:
Frank Morgner 2015-11-26 21:00:38 +01:00
commit 7a2858d7a6
1 changed files with 3 additions and 1 deletions

View File

@ -46,7 +46,9 @@ extern CK_FUNCTION_LIST pkcs11_function_list;
#include <pthread.h> #include <pthread.h>
CK_RV mutex_create(void **mutex) CK_RV mutex_create(void **mutex)
{ {
pthread_mutex_t *m = calloc(1, sizeof(*mutex)); pthread_mutex_t *m;
m = calloc(1, sizeof(*m));
if (m == NULL) if (m == NULL)
return CKR_GENERAL_ERROR;; return CKR_GENERAL_ERROR;;
pthread_mutex_init(m, NULL); pthread_mutex_init(m, NULL);