|
|
0ad27f |
From f1bcadfbe9d156adbe509b0860511ee41add0c67 Mon Sep 17 00:00:00 2001
|
|
|
0ad27f |
From: Frank Morgner <frankmorgner@gmail.com>
|
|
|
0ad27f |
Date: Tue, 10 Mar 2020 12:13:29 +0100
|
|
|
0ad27f |
Subject: [PATCH] pkcs11: don't try to allocate 0 byte with calloc
|
|
|
0ad27f |
|
|
|
0ad27f |
fixes #1978
|
|
|
0ad27f |
---
|
|
|
0ad27f |
src/pkcs11/pkcs11-global.c | 7 ++++++-
|
|
|
0ad27f |
win32/Make.rules.mak | 4 ++--
|
|
|
0ad27f |
win32/winconfig.h.in | 2 ++
|
|
|
0ad27f |
3 files changed, 10 insertions(+), 3 deletions(-)
|
|
|
0ad27f |
|
|
|
0ad27f |
diff --git a/src/pkcs11/pkcs11-global.c b/src/pkcs11/pkcs11-global.c
|
|
|
0ad27f |
index a3260314f8..671890309f 100644
|
|
|
0ad27f |
--- a/src/pkcs11/pkcs11-global.c
|
|
|
0ad27f |
+++ b/src/pkcs11/pkcs11-global.c
|
|
|
0ad27f |
@@ -456,6 +456,13 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
|
|
0ad27f |
|
|
|
0ad27f |
card_detect_all();
|
|
|
0ad27f |
|
|
|
0ad27f |
+ if (list_empty(&virtual_slots)) {
|
|
|
0ad27f |
+ sc_log(context, "returned 0 slots\n");
|
|
|
0ad27f |
+ *pulCount = 0;
|
|
|
0ad27f |
+ rv = CKR_OK;
|
|
|
0ad27f |
+ goto out;
|
|
|
0ad27f |
+ }
|
|
|
0ad27f |
+
|
|
|
0ad27f |
found = calloc(list_size(&virtual_slots), sizeof(CK_SLOT_ID));
|
|
|
0ad27f |
|
|
|
0ad27f |
if (found == NULL) {
|
|
|
0ad27f |
diff --git a/win32/Make.rules.mak b/win32/Make.rules.mak
|
|
|
0ad27f |
index 4f4971a72d..c6b1aac340 100644
|
|
|
0ad27f |
--- a/win32/Make.rules.mak
|
|
|
0ad27f |
+++ b/win32/Make.rules.mak
|
|
|
0ad27f |
@@ -1,7 +1,7 @@
|
|
|
0ad27f |
OPENSC_FEATURES = pcsc
|
|
|
0ad27f |
|
|
|
0ad27f |
#Include support for minidriver
|
|
|
0ad27f |
-MINIDRIVER_DEF = /DENABLE_MINIDRIVER
|
|
|
0ad27f |
+#MINIDRIVER_DEF = /DENABLE_MINIDRIVER
|
|
|
0ad27f |
|
|
|
0ad27f |
#Build MSI with the Windows Installer XML (WIX) toolkit, requires WIX >= 3.9
|
|
|
0ad27f |
!IF "$(WIX)" == ""
|
|
|
0ad27f |
@@ -33,7 +33,7 @@ WIX_LIBS = "$(WIX)\SDK\$(WIXVSVER)\lib\$(PLATFORM)\dutil.lib" "$(WIX)\SDK\$(WIXV
|
|
|
0ad27f |
SM_DEF = /DENABLE_SM
|
|
|
0ad27f |
|
|
|
0ad27f |
#Build with debugging support
|
|
|
0ad27f |
-#DEBUG_DEF = /DDEBUG
|
|
|
0ad27f |
+DEBUG_DEF = /DDEBUG
|
|
|
0ad27f |
|
|
|
0ad27f |
# If you want support for OpenSSL (needed for pkcs15-init tool, software hashing in PKCS#11 library and verification):
|
|
|
0ad27f |
# - download and build OpenSSL
|
|
|
0ad27f |
diff --git a/win32/winconfig.h.in b/win32/winconfig.h.in
|
|
|
0ad27f |
index 94ed9b5475..fa682c5bcc 100644
|
|
|
0ad27f |
--- a/win32/winconfig.h.in
|
|
|
0ad27f |
+++ b/win32/winconfig.h.in
|
|
|
0ad27f |
@@ -103,6 +103,8 @@
|
|
|
0ad27f |
#define DEFAULT_ONEPIN_PKCS11_PROVIDER "@DEFAULT_ONEPIN_PKCS11_PROVIDER@"
|
|
|
0ad27f |
#endif
|
|
|
0ad27f |
|
|
|
0ad27f |
+#define PKCS11_THREAD_LOCKING
|
|
|
0ad27f |
+
|
|
|
0ad27f |
#ifndef DEFAULT_SM_MODULE
|
|
|
0ad27f |
#define DEFAULT_SM_MODULE "@DEFAULT_SM_MODULE@"
|
|
|
0ad27f |
#endif
|
|
|
0ad27f |
|
|
|
0ad27f |
commit 500ecd3d127975379e2310626c3ce94c3e7035ea
|
|
|
0ad27f |
Author: Jakub Jelen <jjelen@redhat.com>
|
|
|
0ad27f |
Date: Wed Nov 25 13:49:08 2020 +0100
|
|
|
0ad27f |
|
|
|
0ad27f |
pkcs11-tool: Avoid calloc with 0 argument
|
|
|
0ad27f |
|
|
|
0ad27f |
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
|
|
|
0ad27f |
index 4015aaf1..89244795 100644
|
|
|
0ad27f |
--- a/src/tools/pkcs11-tool.c
|
|
|
0ad27f |
+++ b/src/tools/pkcs11-tool.c
|
|
|
0ad27f |
@@ -1270,15 +1270,18 @@ static void list_slots(int tokens, int refresh, int print)
|
|
|
0ad27f |
if (rv != CKR_OK)
|
|
|
0ad27f |
p11_fatal("C_GetSlotList(NULL)", rv);
|
|
|
0ad27f |
free(p11_slots);
|
|
|
0ad27f |
- p11_slots = calloc(p11_num_slots, sizeof(CK_SLOT_ID));
|
|
|
0ad27f |
- if (p11_slots == NULL) {
|
|
|
0ad27f |
- perror("calloc failed");
|
|
|
0ad27f |
- exit(1);
|
|
|
0ad27f |
+ p11_slots = NULL;
|
|
|
0ad27f |
+ if (p11_num_slots > 0) {
|
|
|
0ad27f |
+ p11_slots = calloc(p11_num_slots, sizeof(CK_SLOT_ID));
|
|
|
0ad27f |
+ if (p11_slots == NULL) {
|
|
|
0ad27f |
+ perror("calloc failed");
|
|
|
0ad27f |
+ exit(1);
|
|
|
0ad27f |
+ }
|
|
|
0ad27f |
+ rv = p11->C_GetSlotList(tokens, p11_slots, &p11_num_slots);
|
|
|
0ad27f |
+ if (rv != CKR_OK)
|
|
|
0ad27f |
+ p11_fatal("C_GetSlotList()", rv);
|
|
|
0ad27f |
}
|
|
|
0ad27f |
|
|
|
0ad27f |
- rv = p11->C_GetSlotList(tokens, p11_slots, &p11_num_slots);
|
|
|
0ad27f |
- if (rv != CKR_OK)
|
|
|
0ad27f |
- p11_fatal("C_GetSlotList()", rv);
|
|
|
0ad27f |
}
|
|
|
0ad27f |
|
|
|
0ad27f |
if (!print)
|