Better critical preconditions for invalid attributes, from upstream.

This commit is contained in:
ajacoutot 2012-10-16 06:55:21 +00:00
parent 27fa725e85
commit e9d2c2c88a
3 changed files with 138 additions and 1 deletions

View File

@ -1,9 +1,10 @@
# $OpenBSD: Makefile,v 1.13 2012/09/27 17:26:05 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.14 2012/10/16 06:55:21 ajacoutot Exp $
COMMENT= library for storing and retrieving passwords and secrets
GNOME_PROJECT= libsecret
GNOME_VERSION= 0.10
REVISION= 0
SHARED_LIBS += secret-1 0.0 # unknown

View File

@ -0,0 +1,50 @@
$OpenBSD: patch-libsecret_secret-attributes_c,v 1.1 2012/10/16 06:55:21 ajacoutot Exp $
From 7e02a594a77c2730efcc13dd141cc78e201cd7e3 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Fri, 12 Oct 2012 09:27:34 +0000
Subject: Better critical preconditions for invalid attributes
--- libsecret/secret-attributes.c.orig Wed Aug 8 07:48:25 2012
+++ libsecret/secret-attributes.c Tue Oct 16 08:50:16 2012
@@ -153,7 +153,7 @@ secret_attributes_buildv (const SecretSchema *schema,
}
if (!type_found) {
- g_warning ("The attribute '%s' was not found in the password schema.", attribute_name);
+ g_critical ("The attribute '%s' was not found in the password schema.", attribute_name);
g_hash_table_unref (attributes);
return NULL;
}
@@ -165,8 +165,12 @@ secret_attributes_buildv (const SecretSchema *schema,
break;
case SECRET_SCHEMA_ATTRIBUTE_STRING:
string = va_arg (va, gchar *);
+ if (string == NULL) {
+ g_critical ("The value for attribute '%s' was NULL", attribute_name);
+ return NULL;
+ }
if (!g_utf8_validate (string, -1, NULL)) {
- g_warning ("The value for attribute '%s' was not a valid utf-8 string.", attribute_name);
+ g_critical ("The value for attribute '%s' was not a valid UTF-8 string.", attribute_name);
g_hash_table_unref (attributes);
return NULL;
}
@@ -177,7 +181,7 @@ secret_attributes_buildv (const SecretSchema *schema,
value = g_strdup_printf ("%d", integer);
break;
default:
- g_warning ("The password attribute '%s' has an invalid type in the password schema.", attribute_name);
+ g_critical ("The password attribute '%s' has an invalid type in the password schema.", attribute_name);
g_hash_table_unref (attributes);
return NULL;
}
@@ -220,7 +224,7 @@ _secret_attributes_validate (const SecretSchema *schem
}
if (attribute == NULL) {
- g_critical ("%s: invalid %s attribute in for %s schema",
+ g_critical ("%s: invalid %s attribute for %s schema",
pretty_function, key, schema->name);
return FALSE;
}

View File

@ -0,0 +1,86 @@
$OpenBSD: patch-libsecret_secret-password_c,v 1.1 2012/10/16 06:55:21 ajacoutot Exp $
From 7e02a594a77c2730efcc13dd141cc78e201cd7e3 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Fri, 12 Oct 2012 09:27:34 +0000
Subject: Better critical preconditions for invalid attributes
--- libsecret/secret-password.c.orig Wed Aug 8 07:48:25 2012
+++ libsecret/secret-password.c Tue Oct 16 08:50:16 2012
@@ -94,6 +94,10 @@ secret_password_store (const SecretSchema *schema,
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return;
+
secret_password_storev (schema, attributes, collection, label, password,
cancellable, callback, user_data);
@@ -225,6 +229,10 @@ secret_password_store_sync (const SecretSchema *schema
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return FALSE;
+
ret = secret_password_storev_sync (schema, attributes, collection,
label, password, cancellable, error);
@@ -335,6 +343,10 @@ secret_password_lookup (const SecretSchema *schema,
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return;
+
secret_password_lookupv (schema, attributes, cancellable,
callback, user_data);
@@ -468,6 +480,10 @@ secret_password_lookup_sync (const SecretSchema *schem
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return NULL;
+
password = secret_password_lookupv_sync (schema, attributes,
cancellable, error);
@@ -516,6 +532,10 @@ secret_password_lookup_nonpageable_sync (const SecretS
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return NULL;
+
password = secret_password_lookupv_nonpageable_sync (schema, attributes,
cancellable, error);
@@ -668,6 +688,10 @@ secret_password_clear (const SecretSchema *schema,
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return;
+
secret_password_clearv (schema, attributes, cancellable,
callback, user_data);
@@ -768,6 +792,10 @@ secret_password_clear_sync (const SecretSchema* schema
va_start (va, error);
attributes = secret_attributes_buildv (schema, va);
va_end (va);
+
+ /* Precondition failed, already warned */
+ if (!attributes)
+ return FALSE;
result = secret_password_clearv_sync (schema, attributes,
cancellable, error);