[gnome-keyring/dbus-api: 1/6] [pkcs11] Fix assertion when comparing attributes.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api: 1/6] [pkcs11] Fix assertion when comparing attributes.
- Date: Wed, 11 Nov 2009 00:59:32 +0000 (UTC)
commit 782f2ace72e9d30418b6cfc0e4fa2c5352779ede
Author: Stef Walter <stef memberwebs com>
Date: Mon Nov 9 22:23:44 2009 +0000
[pkcs11] Fix assertion when comparing attributes.
When comparing attributes that both had zero lengths, but one
had a null pointer, gck_attribute_equal() used to assert.
pkcs11/gck/gck-attributes.c | 4 +++-
pkcs11/gck/tests/unit-test-attributes.c | 7 +++++++
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/pkcs11/gck/gck-attributes.c b/pkcs11/gck/gck-attributes.c
index 3b48665..f609792 100644
--- a/pkcs11/gck/gck-attributes.c
+++ b/pkcs11/gck/gck-attributes.c
@@ -245,7 +245,9 @@ gck_attribute_equal (gconstpointer v1, gconstpointer v2)
return FALSE;
if (a1->pValue == a2->pValue)
return TRUE;
-
+ if (a1->ulValueLen == 0)
+ return TRUE;
+
g_assert (a1->pValue);
g_assert (a2->pValue);
diff --git a/pkcs11/gck/tests/unit-test-attributes.c b/pkcs11/gck/tests/unit-test-attributes.c
index d8cba87..c56e1b0 100644
--- a/pkcs11/gck/tests/unit-test-attributes.c
+++ b/pkcs11/gck/tests/unit-test-attributes.c
@@ -25,6 +25,13 @@
#include "gck/gck-attributes.h"
+DEFINE_TEST(attribute_equal_zero_len_null_ptr)
+{
+ CK_ATTRIBUTE attr1 = { CKA_LABEL, "", 0 };
+ CK_ATTRIBUTE attr2 = { CKA_LABEL, NULL, 0 };
+ g_assert (gck_attribute_equal (&attr1, &attr2));
+}
+
DEFINE_TEST(attribute_consume)
{
CK_ATTRIBUTE attr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]