Remove more issues with strict aliasing
These would demonstrate with gcc11 and can be detected with gcc flag -Wstrict-aliasing=2 (also with older gcc)
This commit is contained in:
parent
45e262f537
commit
2fa6700599
|
@ -673,6 +673,7 @@ __pkcs15_create_cert_object(struct pkcs15_fw_data *fw_data, struct sc_pkcs15_obj
|
|||
struct pkcs15_any_object *any_object = NULL;
|
||||
struct pkcs15_cert_object *object = NULL;
|
||||
struct pkcs15_pubkey_object *obj2 = NULL;
|
||||
struct pkcs15_any_object *any_object2 = NULL;
|
||||
int rv;
|
||||
|
||||
p15_info = (struct sc_pkcs15_cert_info *) cert->data;
|
||||
|
@ -700,10 +701,11 @@ __pkcs15_create_cert_object(struct pkcs15_fw_data *fw_data, struct sc_pkcs15_obj
|
|||
object->cert_data = p15_cert;
|
||||
|
||||
/* Corresponding public key */
|
||||
rv = public_key_created(fw_data, &p15_info->id, (struct pkcs15_any_object **) &obj2);
|
||||
rv = public_key_created(fw_data, &p15_info->id, &any_object2);
|
||||
if (rv != SC_SUCCESS)
|
||||
rv = __pkcs15_create_object(fw_data, (struct pkcs15_any_object **) &obj2,
|
||||
rv = __pkcs15_create_object(fw_data, &any_object2,
|
||||
NULL, &pkcs15_pubkey_ops, sizeof(struct pkcs15_pubkey_object));
|
||||
obj2 = (struct pkcs15_pubkey_object *) any_object2;
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
|
@ -2975,14 +2977,17 @@ set_gost3410_params(struct sc_pkcs15init_prkeyargs *prkey_args,
|
|||
const CK_BYTE * gost_params_encoded_oid_from_template;
|
||||
const CK_BYTE * gost_hash_params_encoded_oid_from_template;
|
||||
size_t len, param_index, hash_index;
|
||||
void *ptr = NULL;
|
||||
CK_RV rv;
|
||||
|
||||
/* If template has CKA_GOSTR3410_PARAMS attribute, set param_index to
|
||||
* corresponding item's index in gostr3410_param_oid[] */
|
||||
if (pPrivTpl && ulPrivCnt)
|
||||
rv = attr_find_ptr2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt, CKA_GOSTR3410_PARAMS, (void **)&gost_params_encoded_oid_from_template, &len);
|
||||
else
|
||||
rv = attr_find_ptr(pPubTpl, ulPubCnt, CKA_GOSTR3410_PARAMS, (void **)&gost_params_encoded_oid_from_template, &len);
|
||||
if (pPrivTpl && ulPrivCnt) {
|
||||
rv = attr_find_ptr2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt, CKA_GOSTR3410_PARAMS, &ptr, &len);
|
||||
} else {
|
||||
rv = attr_find_ptr(pPubTpl, ulPubCnt, CKA_GOSTR3410_PARAMS, &ptr, &len);
|
||||
}
|
||||
gost_params_encoded_oid_from_template = (const CK_BYTE *) ptr;
|
||||
|
||||
if (rv == CKR_OK) {
|
||||
size_t nn = sizeof(gostr3410_param_oid)/sizeof(gostr3410_param_oid[0]);
|
||||
|
@ -3005,10 +3010,12 @@ set_gost3410_params(struct sc_pkcs15init_prkeyargs *prkey_args,
|
|||
|
||||
/* If template has CKA_GOSTR3411_PARAMS attribute, set hash_index to
|
||||
* corresponding item's index in gostr3410_hash_param_oid[] */
|
||||
if (pPrivTpl && ulPrivCnt)
|
||||
rv = attr_find_ptr2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt, CKA_GOSTR3411_PARAMS, (void **)&gost_hash_params_encoded_oid_from_template, &len);
|
||||
else
|
||||
rv = attr_find_ptr(pPubTpl, ulPubCnt, CKA_GOSTR3411_PARAMS, (void **)&gost_hash_params_encoded_oid_from_template, &len);
|
||||
if (pPrivTpl && ulPrivCnt) {
|
||||
rv = attr_find_ptr2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt, CKA_GOSTR3411_PARAMS, &ptr, &len);
|
||||
} else {
|
||||
rv = attr_find_ptr(pPubTpl, ulPubCnt, CKA_GOSTR3411_PARAMS, &ptr, &len);
|
||||
}
|
||||
gost_hash_params_encoded_oid_from_template = ptr;
|
||||
|
||||
if (rv == CKR_OK) {
|
||||
size_t nn = sizeof(gostr3410_hash_param_oid)/sizeof(gostr3410_hash_param_oid[0]);
|
||||
|
@ -3155,9 +3162,11 @@ pkcs15_gen_keypair(struct sc_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism,
|
|||
}
|
||||
else if (keytype == CKK_EC) {
|
||||
struct sc_lv_data *der = &keygen_args.prkey_args.key.u.ec.params.der;
|
||||
void *ptr = NULL;
|
||||
|
||||
der->len = sizeof(struct sc_object_id);
|
||||
rv = attr_find_and_allocate_ptr(pPubTpl, ulPubCnt, CKA_EC_PARAMS, (void **)&der->value, &der->len);
|
||||
rv = attr_find_and_allocate_ptr(pPubTpl, ulPubCnt, CKA_EC_PARAMS, &ptr, &der->len);
|
||||
der->value = (unsigned char *) ptr;
|
||||
if (rv != CKR_OK) {
|
||||
sc_unlock(p11card->card);
|
||||
return sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
|
||||
|
|
|
@ -347,6 +347,7 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
struct sc_pkcs11_object *object;
|
||||
struct sc_pkcs11_find_operation *operation;
|
||||
struct sc_pkcs11_slot *slot;
|
||||
struct sc_pkcs11_operation *op = NULL;
|
||||
|
||||
if (pTemplate == NULL_PTR && ulCount > 0)
|
||||
return CKR_ARGUMENTS_BAD;
|
||||
|
@ -363,7 +364,8 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
dump_template(SC_LOG_DEBUG_NORMAL, "C_FindObjectsInit()", pTemplate, ulCount);
|
||||
|
||||
rv = session_start_operation(session, SC_PKCS11_OPERATION_FIND,
|
||||
&find_mechanism, (struct sc_pkcs11_operation **)&operation);
|
||||
&find_mechanism, &op);
|
||||
operation = (struct sc_pkcs11_find_operation *) op;
|
||||
if (rv != CKR_OK)
|
||||
goto out;
|
||||
|
||||
|
@ -451,6 +453,7 @@ C_FindObjects(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
CK_ULONG to_return;
|
||||
struct sc_pkcs11_session *session;
|
||||
struct sc_pkcs11_find_operation *operation;
|
||||
struct sc_pkcs11_operation *op = NULL;
|
||||
|
||||
if (phObject == NULL_PTR || ulMaxObjectCount == 0 || pulObjectCount == NULL_PTR)
|
||||
return CKR_ARGUMENTS_BAD;
|
||||
|
@ -463,7 +466,8 @@ C_FindObjects(CK_SESSION_HANDLE hSession, /* the session's handle */
|
|||
if (rv != CKR_OK)
|
||||
goto out;
|
||||
|
||||
rv = session_get_operation(session, SC_PKCS11_OPERATION_FIND, (sc_pkcs11_operation_t **) & operation);
|
||||
rv = session_get_operation(session, SC_PKCS11_OPERATION_FIND, &op);
|
||||
operation = (struct sc_pkcs11_find_operation *) op;
|
||||
if (rv != CKR_OK)
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -123,13 +123,15 @@ add_module_pkcs11_txt(const char *profile_dir,
|
|||
char pkcs11_txt_path[PATH_MAX];
|
||||
char *pkcs11_txt = NULL;
|
||||
size_t pkcs11_txt_len = 0;
|
||||
unsigned char *txt = NULL;
|
||||
|
||||
if (!profile_dir
|
||||
|| snprintf(pkcs11_txt_path, sizeof pkcs11_txt_path,
|
||||
"%s%c%s", profile_dir, path_sep, "pkcs11.txt") < 0
|
||||
|| !fread_to_eof(pkcs11_txt_path,
|
||||
(unsigned char **) &pkcs11_txt, &pkcs11_txt_len)) {
|
||||
|| !fread_to_eof(pkcs11_txt_path, &txt, &pkcs11_txt_len)) {
|
||||
goto err;
|
||||
}
|
||||
pkcs11_txt = (char *)txt;
|
||||
char *p = realloc(pkcs11_txt, pkcs11_txt_len+1);
|
||||
if (!p)
|
||||
goto err;
|
||||
|
|
Loading…
Reference in New Issue