[lasem] lsm: handle invalid attribute and property values.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] lsm: handle invalid attribute and property values.
- Date: Tue, 3 Aug 2010 18:57:57 +0000 (UTC)
commit 8962afb61c81b9dde5ca03c5d05a326536689456
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Tue Aug 3 20:57:24 2010 +0200
lsm: handle invalid attribute and property values.
src/lsmattributes.c | 36 +++++++++++++++++++++++++-----------
src/lsmproperties.c | 14 ++++++++++++--
2 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/src/lsmattributes.c b/src/lsmattributes.c
index ffd1fcf..4b2b15c 100644
--- a/src/lsmattributes.c
+++ b/src/lsmattributes.c
@@ -137,19 +137,33 @@ lsm_attribute_manager_set_attribute (LsmAttributeManager *manager,
attribute->value = g_strdup (value);
if (attribute->value != NULL) {
- if (trait_class->from_string)
- trait_class->from_string (ATTRIBUTE_TRAIT (attribute), (char *) value);
- } else {
- if (trait_class->init)
- trait_class->init (ATTRIBUTE_TRAIT (attribute), attribute_infos->trait_default);
- else
- /* Simple memcpy for default init implementation, discarded by a NULL default value. */
- if (attribute_infos->trait_default != NULL)
- memcpy (ATTRIBUTE_TRAIT (attribute),
- attribute_infos->trait_default,
- trait_class->size);
+ if (trait_class->from_string) {
+ gboolean success;
+
+ success = trait_class->from_string (ATTRIBUTE_TRAIT (attribute), (char *) value);
+ if (success)
+ return TRUE;
+
+ if (trait_class->finalize)
+ trait_class->finalize (ATTRIBUTE_TRAIT (attribute));
+ g_free (attribute->value);
+ attribute->value = NULL;
+
+ lsm_debug ("[LsmAttributeManager::set_attribute] Invalid attribute value %s='%s'",
+ name, value);
+ } else
+ return TRUE;
}
+ if (trait_class->init)
+ trait_class->init (ATTRIBUTE_TRAIT (attribute), attribute_infos->trait_default);
+ else
+ /* Simple memcpy for default init implementation, discarded by a NULL default value. */
+ if (attribute_infos->trait_default != NULL)
+ memcpy (ATTRIBUTE_TRAIT (attribute),
+ attribute_infos->trait_default,
+ trait_class->size);
+
return TRUE;
}
diff --git a/src/lsmproperties.c b/src/lsmproperties.c
index c0dc84d..934d48a 100644
--- a/src/lsmproperties.c
+++ b/src/lsmproperties.c
@@ -104,8 +104,18 @@ _set_property (LsmPropertyManager *manager,
if (trait_class->init)
trait_class->init (PROPERTY_TRAIT (property), NULL);
- if (property->value != NULL && trait_class->from_string)
- trait_class->from_string (PROPERTY_TRAIT (property), (char *) value);
+ if (property->value != NULL && trait_class->from_string) {
+ gboolean success;
+
+ success = trait_class->from_string (PROPERTY_TRAIT (property), (char *) value);
+ if (!success) {
+ lsm_debug ("[LsmPropertyManager::set_property] Invalid property value %s='%s'",
+ name, value);
+ property_free (property, property_infos->trait_class);
+
+ return FALSE;
+ }
+ }
property_bag->properties = g_slist_prepend (property_bag->properties, property);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]