Avoid another strict-aliasing issues on 32b architectures

This commit is contained in:
Jakub Jelen 2021-02-25 19:57:26 +01:00
parent 6d99cac994
commit fae5c1d31f

View File

@ -325,3 +325,37 @@ index 007ff1ae..873ebcba 100644
char *p = realloc(pkcs11_txt, pkcs11_txt_len+1); char *p = realloc(pkcs11_txt, pkcs11_txt_len+1);
if (!p) if (!p)
goto err; goto err;
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index a4d9c94b..35b96792 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -6303,11 +6303,12 @@ static CK_SESSION_HANDLE test_kpgen_certwrite(CK_SLOT_ID slot, CK_SESSION_HANDLE
return session;
}
- tmp = getID(session, priv_key, (CK_ULONG *) &opt_object_id_len);
- if (opt_object_id_len == 0) {
+ tmp = getID(session, priv_key, &i);
+ if (i == 0) {
fprintf(stderr, "ERR: newly generated private key has no (or an empty) CKA_ID\n");
return session;
}
+ opt_object_id_len = (size_t) i;
memcpy(opt_object_id, tmp, opt_object_id_len);
/* This is done in NSS */
@@ -6485,11 +6486,12 @@ static void test_ec(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
if (!gen_keypair(slot, session, &pub_key, &priv_key, opt_key_type))
return;
- tmp = getID(session, priv_key, (CK_ULONG *) &opt_object_id_len);
- if (opt_object_id_len == 0) {
+ tmp = getID(session, priv_key, &i);
+ if (i == 0) {
printf("ERR: newly generated private key has no (or an empty) CKA_ID\n");
return;
}
+ i = (size_t) opt_object_id_len;
memcpy(opt_object_id, tmp, opt_object_id_len);
/* This is done in NSS */