pkcs11-tool: Avoid strict-aliasing issues on 32b architectures

This commit is contained in:
Jakub Jelen 2021-02-25 19:28:30 +01:00 committed by Frank Morgner
parent 544dcc6827
commit 63031b2193
1 changed files with 6 additions and 4 deletions

View File

@ -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 */