aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hx509/softp11.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hx509/softp11.c')
-rw-r--r--lib/hx509/softp11.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/hx509/softp11.c b/lib/hx509/softp11.c
index 38f587e0fea2..f93863b7c980 100644
--- a/lib/hx509/softp11.c
+++ b/lib/hx509/softp11.c
@@ -34,7 +34,7 @@
#define CRYPTOKI_EXPORTS 1
#include "hx_locl.h"
-#include "pkcs11.h"
+#include "ref/pkcs11.h"
#define OBJECT_ID_MASK 0xfff
#define HANDLE_OBJECT_ID(h) ((h) & OBJECT_ID_MASK)
@@ -543,6 +543,8 @@ add_cert(hx509_context hxctx, void *ctx, hx509_cert cert)
CK_FLAGS flags;
type = CKO_PRIVATE_KEY;
+
+ /* Note to static analyzers: `o' is still referred to via globals */
o = add_st_object();
if (o == NULL) {
ret = CKR_DEVICE_MEMORY;
@@ -593,6 +595,7 @@ add_cert(hx509_context hxctx, void *ctx, hx509_cert cert)
hx509_xfree(issuer_data.data);
hx509_xfree(subject_data.data);
+ /* Note to static analyzers: `o' is still referred to via globals */
return 0;
}
@@ -615,7 +618,11 @@ add_certificate(const char *cert_file,
if (pin) {
char *str;
- asprintf(&str, "PASS:%s", pin);
+ ret = asprintf(&str, "PASS:%s", pin);
+ if (ret == -1 || !str) {
+ st_logf("failed to allocate memory\n");
+ return CKR_GENERAL_ERROR;
+ }
hx509_lock_init(context, &lock);
hx509_lock_command_string(lock, str);
@@ -815,6 +822,7 @@ get_config_file_for_user(void)
#ifndef _WIN32
char *home = NULL;
+ int ret;
if (!issuid()) {
fn = getenv("SOFTPKCS11RC");
@@ -828,9 +836,11 @@ get_config_file_for_user(void)
home = pw->pw_dir;
}
if (fn == NULL) {
- if (home)
- asprintf(&fn, "%s/.soft-token.rc", home);
- else
+ if (home) {
+ ret = asprintf(&fn, "%s/.soft-token.rc", home);
+ if (ret == -1)
+ fn = NULL;
+ } else
fn = strdup("/etc/soft-token.rc");
}
#else /* Windows */
@@ -1077,7 +1087,7 @@ C_GetMechanismList(CK_SLOT_ID slotID,
*pulCount = 1;
if (pMechanismList == NULL_PTR)
return CKR_OK;
- pMechanismList[1] = CKM_RSA_PKCS;
+ pMechanismList[0] = CKM_RSA_PKCS;
return CKR_OK;
}
@@ -1205,8 +1215,13 @@ C_Login(CK_SESSION_HANDLE hSession,
VERIFY_SESSION_HANDLE(hSession, NULL);
if (pPin != NULL_PTR) {
- asprintf(&pin, "%.*s", (int)ulPinLen, pPin);
- st_logf("type: %d password: %s\n", (int)userType, pin);
+ int aret;
+
+ aret = asprintf(&pin, "%.*s", (int)ulPinLen, pPin);
+ if (aret != -1 && pin)
+ st_logf("type: %d password: %s\n", (int)userType, pin);
+ else
+ st_logf("memory error: asprintf failed\n");
}
/*