Fix crash when hashing an unsupported attributes (from upstream).

This commit is contained in:
ajacoutot 2013-03-22 11:05:59 +00:00
parent cf584dadbe
commit f182f8c317
4 changed files with 88 additions and 18 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.16 2013/03/11 11:46:10 espie Exp $
# $OpenBSD: Makefile,v 1.17 2013/03/22 11:05:59 ajacoutot Exp $
COMMENT= library for bits of crypto UI and parsing
GNOME_PROJECT= gcr
GNOME_VERSION= 3.6.2
REVISION= 0
REVISION= 1
SHARED_LIBS += gck-1 1.0 # 0.0
SHARED_LIBS += gcr-3 2.0 # 1.0
@ -17,10 +17,10 @@ WANTLIB += ICE SM X11 Xcomposite Xcursor Xdamage Xext Xfixes Xi
WANTLIB += Xinerama Xrandr Xrender atk-1.0 atk-bridge-2.0 atspi
WANTLIB += c cairo cairo-gobject dbus-1 expat ffi fontconfig freetype
WANTLIB += gcrypt gdk-3 gdk_pixbuf-2.0 gio-2.0 glib-2.0 gmodule-2.0
WANTLIB += gobject-2.0 gpg-error gthread-2.0 gtk-3 harfbuzz icudata
WANTLIB += icule icuuc m p11-kit pango-1.0 pangocairo-1.0 pangoft2-1.0
WANTLIB += pcre pixman-1 png pthread pthread-stubs xcb xcb-render
WANTLIB += xcb-shm z
WANTLIB += gobject-2.0 gpg-error graphite2 gthread-2.0 gtk-3 harfbuzz
WANTLIB += icudata icule icuuc m p11-kit pango-1.0 pangocairo-1.0
WANTLIB += pangoft2-1.0 pcre pixman-1 png pthread pthread-stubs
WANTLIB += xcb xcb-render xcb-shm z
MODULES= devel/gettext \
x11/gnome \
@ -53,12 +53,6 @@ post-patch:
AUTOCONF_VERSION=${AUTOCONF_VERSION} \
AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
autoreconf -i
@find ${WRKSRC} -name Makefile.am | xargs \
perl -pi -e 's|sed -i|perl -pi|g'
### end remove
pre-configure:
find ${WRKSRC} -name Makefile.in | xargs \
perl -pi -e 's|sed -i|perl -pi|g'
.include <bsd.port.mk>

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-gck_gck-attributes_c,v 1.1 2013/03/22 11:05:59 ajacoutot Exp $
From c96aa2795ffa0c3305787c237dc223571b4934b4 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Thu, 21 Mar 2013 17:32:07 +0000
Subject: gck: Fix crash when hashing an unsupported attributes
--- gck/gck-attributes.c.orig Sat Oct 27 15:03:44 2012
+++ gck/gck-attributes.c Fri Mar 22 11:52:36 2013
@@ -1996,8 +1996,10 @@ gck_attribute_hash (gconstpointer attr)
h ^= _gck_ulong_hash (&a->type);
- for (p = (signed char *)a->value, e = p + a->length; p != e; p++)
- h = (h << 5) + h + *p;
+ if (a->value) {
+ for (p = (signed char *)a->value, e = p + a->length; p != e; p++)
+ h = (h << 5) + h + *p;
+ }
return h;
}

View File

@ -1,12 +1,17 @@
$OpenBSD: patch-gck_tests_test-gck-attributes_c,v 1.2 2012/11/12 08:13:34 ajacoutot Exp $
$OpenBSD: patch-gck_tests_test-gck-attributes_c,v 1.3 2013/03/22 11:05:59 ajacoutot Exp $
From aeae080e778c5168eae22b3271d60fc6bc7e1482 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Fri, 09 Nov 2012 13:06:41 +0000
Subject: gck: Remove duplicate defined symbol
--- gck/tests/test-gck-attributes.c.orig Sat Nov 10 10:49:40 2012
+++ gck/tests/test-gck-attributes.c Sat Nov 10 10:49:45 2012
From c96aa2795ffa0c3305787c237dc223571b4934b4 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Thu, 21 Mar 2013 17:32:07 +0000
Subject: gck: Fix crash when hashing an unsupported attributes
--- gck/tests/test-gck-attributes.c.orig Mon Nov 12 08:30:20 2012
+++ gck/tests/test-gck-attributes.c Fri Mar 22 11:52:36 2013
@@ -31,8 +31,6 @@
#include "gck/gck.h"
#include "gck/gck-test.h"
@ -16,3 +21,43 @@ Subject: gck: Remove duplicate defined symbol
EGG_SECURE_DECLARE (test_gck_attributes);
#define ATTR_TYPE 55
@@ -963,6 +961,31 @@ test_builder_add_attr (void)
}
static void
+test_attribute_hash (void)
+{
+ guchar *data = (guchar *)"extra attribute";
+ GckAttribute one = { CKA_LABEL, (guchar *)"yay", 3 };
+ GckAttribute null = { CKA_LABEL, (guchar *)NULL, 3 };
+ GckAttribute zero = { CKA_LABEL, (guchar *)NULL, 0 };
+ GckAttribute two = { CKA_VALUE, (guchar *)"yay", 3 };
+ GckAttribute other = { CKA_VALUE, data, 5 };
+ GckAttribute overflow = { CKA_VALUE, data, 5 };
+ GckAttribute content = { CKA_VALUE, (guchar *)"conte", 5 };
+ guint hash;
+
+ hash = gck_attribute_hash (&one);
+ g_assert_cmpuint (hash, !=, 0);
+
+ g_assert_cmpuint (gck_attribute_hash (&one), ==, hash);
+ g_assert_cmpuint (gck_attribute_hash (&two), !=, hash);
+ g_assert_cmpuint (gck_attribute_hash (&other), !=, hash);
+ g_assert_cmpuint (gck_attribute_hash (&overflow), !=, hash);
+ g_assert_cmpuint (gck_attribute_hash (&null), !=, hash);
+ g_assert_cmpuint (gck_attribute_hash (&zero), !=, hash);
+ g_assert_cmpuint (gck_attribute_hash (&content), !=, hash);
+}
+
+static void
test_attributes_refs (void)
{
GckBuilder builder = GCK_BUILDER_INIT;
@@ -1301,6 +1324,7 @@ main (int argc, char **argv)
g_test_add_func ("/gck/attribute/get_string", test_get_string);
g_test_add_func ("/gck/attribute/dup_attribute", test_dup_attribute);
g_test_add_func ("/gck/attribute/copy_attribute", test_copy_attribute);
+ g_test_add_func ("/gck/attribute/hash", test_attribute_hash);
g_test_add_func ("/gck/builder/blank", test_builder_blank);
g_test_add_func ("/gck/builder/data", test_build_data);
g_test_add_func ("/gck/builder/data-invalid", test_build_data_invalid);

View File

@ -1,12 +1,12 @@
$OpenBSD: patch-gcr_Makefile_am,v 1.1 2013/03/08 06:39:05 ajacoutot Exp $
$OpenBSD: patch-gcr_Makefile_am,v 1.2 2013/03/22 11:05:59 ajacoutot Exp $
From 35ca5d5ab45da27cca21bf0d5404429fd1c4224d Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Tue, 12 Feb 2013 06:10:12 +0000
Subject: Don't export duplicate secmem symbols
--- gcr/Makefile.am.orig Thu Feb 21 10:06:28 2013
+++ gcr/Makefile.am Thu Feb 21 10:06:39 2013
--- gcr/Makefile.am.orig Sat Oct 27 15:03:06 2012
+++ gcr/Makefile.am Fri Mar 22 11:51:55 2013
@@ -131,7 +131,6 @@ libgcr_base_@GCR_MAJOR@_la_SOURCES = \
gcr-internal.h \
gcr-key-mechanisms.h gcr-key-mechanisms.c \
@ -23,3 +23,12 @@ Subject: Don't export duplicate secmem symbols
gcr-memory-icon.c gcr-memory-icon.h \
gcr-pkcs11-import-interaction.c gcr-pkcs11-import-interaction.h \
gcr-pkcs11-import-dialog.c gcr-pkcs11-import-dialog.h \
@@ -271,7 +269,7 @@ DBUS_XML_DEFINITIONS = \
gcr-dbus-generated.c: $(DBUS_XML_DEFINITIONS)
$(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.keyring.internal. \
--generate-c-code gcr-dbus-generated --c-namespace GcrDBus $^
- $(AM_V_GEN) sed -i -e 's/gcr_dbus/_gcr_dbus/g' gcr-dbus-generated.[ch]
+ $(AM_V_GEN) perl -pi -e 's/gcr_dbus/_gcr_dbus/g' gcr-dbus-generated.[ch]
gcr-dbus-generated.h: gcr-dbus-generated.c