pkcs11: use calloc instead of malloc; remove obsolete malloc.h references.
This commit is contained in:
parent
3b4f7b9ff7
commit
32ed309037
|
@ -243,7 +243,7 @@ AC_HEADER_STDC
|
||||||
AC_HEADER_SYS_WAIT
|
AC_HEADER_SYS_WAIT
|
||||||
AC_HEADER_ASSERT
|
AC_HEADER_ASSERT
|
||||||
AC_CHECK_HEADERS([ \
|
AC_CHECK_HEADERS([ \
|
||||||
errno.h fcntl.h malloc.h stdlib.h \
|
errno.h fcntl.h stdlib.h \
|
||||||
inttypes.h string.h strings.h \
|
inttypes.h string.h strings.h \
|
||||||
sys/time.h unistd.h getopt.h sys/mman.h
|
sys/time.h unistd.h getopt.h sys/mman.h
|
||||||
])
|
])
|
||||||
|
|
|
@ -4052,13 +4052,12 @@ static int pkcs15_skey_get_value(struct sc_pkcs11_session *session,
|
||||||
* but for now we only work with session objects
|
* but for now we only work with session objects
|
||||||
* derived from other keys
|
* derived from other keys
|
||||||
*/
|
*/
|
||||||
skey_data= malloc(sizeof(struct sc_pkcs15_skey));
|
skey_data= calloc(1, sizeof(struct sc_pkcs15_skey));
|
||||||
if (skey_data == NULL)
|
if (skey_data == NULL)
|
||||||
return SC_ERROR_OUT_OF_MEMORY;
|
return SC_ERROR_OUT_OF_MEMORY;
|
||||||
memset(skey_data, 0, sizeof(struct sc_pkcs15_skey));
|
|
||||||
|
|
||||||
if (skey->value && skey->value->data_len) {
|
if (skey->value && skey->value->data_len) {
|
||||||
skey_data->data = malloc(skey_data->data_len);
|
skey_data->data = calloc(1, skey_data->data_len);
|
||||||
if (skey_data->data == NULL) {
|
if (skey_data->data == NULL) {
|
||||||
free(skey_data);
|
free(skey_data);
|
||||||
return SC_ERROR_OUT_OF_MEMORY;
|
return SC_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -673,7 +673,7 @@ sc_pkcs11_verify_final(sc_pkcs11_operation_t *operation,
|
||||||
rv = key->ops->get_attribute(operation->session, key, &attr);
|
rv = key->ops->get_attribute(operation->session, key, &attr);
|
||||||
if (rv != CKR_OK)
|
if (rv != CKR_OK)
|
||||||
return rv;
|
return rv;
|
||||||
pubkey_value = malloc(attr.ulValueLen);
|
pubkey_value = calloc(1, attr.ulValueLen);
|
||||||
attr.pValue = pubkey_value;
|
attr.pValue = pubkey_value;
|
||||||
rv = key->ops->get_attribute(operation->session, key, &attr);
|
rv = key->ops->get_attribute(operation->session, key, &attr);
|
||||||
if (rv != CKR_OK)
|
if (rv != CKR_OK)
|
||||||
|
|
|
@ -420,7 +420,7 @@ CK_RV sc_pkcs11_verify_data(const unsigned char *pubkey, int pubkey_len,
|
||||||
if (rsa == NULL)
|
if (rsa == NULL)
|
||||||
return CKR_DEVICE_MEMORY;
|
return CKR_DEVICE_MEMORY;
|
||||||
|
|
||||||
rsa_out = malloc(RSA_size(rsa));
|
rsa_out = calloc(1, RSA_size(rsa));
|
||||||
if (rsa_out == NULL) {
|
if (rsa_out == NULL) {
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
return CKR_DEVICE_MEMORY;
|
return CKR_DEVICE_MEMORY;
|
||||||
|
|
|
@ -42,7 +42,7 @@ 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 = malloc(sizeof(*mutex));
|
pthread_mutex_t *m = calloc(1, sizeof(*mutex));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return CKR_GENERAL_ERROR;;
|
return CKR_GENERAL_ERROR;;
|
||||||
pthread_mutex_init(m, NULL);
|
pthread_mutex_init(m, NULL);
|
||||||
|
@ -80,7 +80,7 @@ CK_RV mutex_create(void **mutex)
|
||||||
{
|
{
|
||||||
CRITICAL_SECTION *m;
|
CRITICAL_SECTION *m;
|
||||||
|
|
||||||
m = malloc(sizeof(*m));
|
m = calloc(1, sizeof(*m));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return CKR_GENERAL_ERROR;
|
return CKR_GENERAL_ERROR;
|
||||||
InitializeCriticalSection(m);
|
InitializeCriticalSection(m);
|
||||||
|
@ -385,7 +385,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
||||||
|
|
||||||
card_detect_all();
|
card_detect_all();
|
||||||
|
|
||||||
found = malloc(list_size(&virtual_slots) * sizeof(CK_SLOT_ID));
|
found = calloc(list_size(&virtual_slots), sizeof(CK_SLOT_ID));
|
||||||
|
|
||||||
if (found == NULL) {
|
if (found == NULL) {
|
||||||
rv = CKR_HOST_MEMORY;
|
rv = CKR_HOST_MEMORY;
|
||||||
|
|
|
@ -1352,7 +1352,7 @@ int sc_pkcs11_any_cmp_attribute(struct sc_pkcs11_session *session, void *ptr, CK
|
||||||
if (temp_attr.ulValueLen <= sizeof(temp1))
|
if (temp_attr.ulValueLen <= sizeof(temp1))
|
||||||
temp_attr.pValue = temp1;
|
temp_attr.pValue = temp1;
|
||||||
else {
|
else {
|
||||||
temp2 = malloc(temp_attr.ulValueLen);
|
temp2 = calloc(1, temp_attr.ulValueLen);
|
||||||
if (temp2 == NULL)
|
if (temp2 == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
temp_attr.pValue = temp2;
|
temp_attr.pValue = temp2;
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_MALLOC_H
|
|
||||||
#include <malloc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libopensc/opensc.h"
|
#include "libopensc/opensc.h"
|
||||||
#include "libopensc/pkcs15.h"
|
#include "libopensc/pkcs15.h"
|
||||||
#include "libopensc/log.h"
|
#include "libopensc/log.h"
|
||||||
|
|
Loading…
Reference in New Issue