summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2013-07-17 18:55:38 +0200
committerStef Walter <stef@thewalter.net>2013-07-18 13:04:37 +0200
commit1548d82560b242579f5ba216b66bd59ccd0f3fd0 (patch)
tree2168b80fb86a9500514706f5402038976061e196
parent29a5df009656dc09be781c4939cec3613a0a12cb (diff)
downloadp11-kit-1548d82560b242579f5ba216b66bd59ccd0f3fd0.tar.gz
Don't call memdup with zero length or NULL pointer
https://bugzilla.redhat.com/show_bug.cgi?id=985433
-rw-r--r--common/attrs.c9
-rw-r--r--p11-kit/pin.c2
2 files changed, 8 insertions, 3 deletions
diff --git a/common/attrs.c b/common/attrs.c
index b06a342..9f3e522 100644
--- a/common/attrs.c
+++ b/common/attrs.c
@@ -143,8 +143,13 @@ attrs_build (CK_ATTRIBUTE *attrs,
}
memcpy (attr, add, sizeof (CK_ATTRIBUTE));
- if (!take_values)
- attr->pValue = memdup (attr->pValue, attr->ulValueLen);
+ if (!take_values && attr->pValue != NULL) {
+ if (attr->ulValueLen == 0)
+ attr->pValue = malloc (1);
+ else
+ attr->pValue = memdup (attr->pValue, attr->ulValueLen);
+ return_val_if_fail (attr->pValue != NULL, NULL);
+ }
}
/* Mark this as the end */
diff --git a/p11-kit/pin.c b/p11-kit/pin.c
index 60571de..2fca6bc 100644
--- a/p11-kit/pin.c
+++ b/p11-kit/pin.c
@@ -357,7 +357,7 @@ p11_kit_pin_request (const char *pin_source,
if (callbacks == NULL)
callbacks = p11_dict_get (gl.pin_sources, P11_KIT_PIN_FALLBACK);
- if (callbacks != NULL) {
+ if (callbacks != NULL && callbacks->num) {
snapshot = memdup (callbacks->elem, sizeof (void *) * callbacks->num);
snapshot_count = callbacks->num;
for (i = 0; snapshot && i < snapshot_count; i++)