[gnome-keyring/wip/dueno/ubsan: 5/5] pkcs11: Fix load of misaligned address
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/wip/dueno/ubsan: 5/5] pkcs11: Fix load of misaligned address
- Date: Tue, 24 Sep 2019 04:53:33 +0000 (UTC)
commit bf04c45535dc9fae80d3beead16fcd760989b44e
Author: Daiki Ueno <dueno src gnome org>
Date: Mon Sep 16 16:34:30 2019 +0200
pkcs11: Fix load of misaligned address
pkcs11/gkm/gkm-attributes.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/pkcs11/gkm/gkm-attributes.c b/pkcs11/gkm/gkm-attributes.c
index fb185bc0..dfdd08f3 100644
--- a/pkcs11/gkm/gkm-attributes.c
+++ b/pkcs11/gkm/gkm-attributes.c
@@ -518,8 +518,11 @@ gkm_attributes_find_boolean (CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs, CK_ATTRIB
if (attr->ulValueLen != sizeof (CK_BBOOL))
return FALSE;
- if (value != NULL)
- *value = *((CK_BBOOL*)attr->pValue) == CK_TRUE ? TRUE : FALSE;
+ if (value != NULL) {
+ CK_BBOOL bbool;
+ memcpy (&bbool, attr->pValue, sizeof (CK_BBOOL));
+ *value = bbool == CK_TRUE ? TRUE : FALSE;
+ }
return TRUE;
}
@@ -538,8 +541,11 @@ gkm_attributes_find_ulong (CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs, CK_ATTRIBUT
if (attr->ulValueLen != sizeof (CK_ULONG))
return FALSE;
- if (value != NULL)
- *value = *((CK_ULONG*)attr->pValue);
+ if (value != NULL) {
+ CK_ULONG ulong;
+ memcpy (&ulong, attr->pValue, sizeof (CK_ULONG));
+ *value = ulong;
+ }
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]