]> err.no Git - systemd/commitdiff
dbus: handle invalid enum values better
authorLennart Poettering <lennart@poettering.net>
Thu, 3 May 2012 21:06:19 +0000 (23:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 May 2012 21:06:19 +0000 (23:06 +0200)
src/shared/dbus-common.h

index 859812900dec6288f769102b8db5ffbcc81305d0..edb8107347a7d538e257b2149f9a75b8acd574ab 100644 (file)
@@ -155,7 +155,7 @@ int bus_property_set_uint64(DBusMessageIter *i, const char *property, void *data
                 assert(i);                                              \
                 assert(property);                                       \
                                                                         \
-                value = name##_to_string(*field);                       \
+                value = strempty(name##_to_string(*field));             \
                                                                         \
                 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &value)) \
                         return -ENOMEM;                                 \
@@ -166,15 +166,18 @@ int bus_property_set_uint64(DBusMessageIter *i, const char *property, void *data
 #define DEFINE_BUS_PROPERTY_SET_ENUM(function,name,type)                \
         int function(DBusMessageIter *i, const char *property, void *data) { \
                 const char *value;                                      \
-                type *field = data;                                     \
+                type f, *field = data;                                  \
                                                                         \
                 assert(i);                                              \
                 assert(property);                                       \
                                                                         \
                 dbus_message_iter_get_basic(i, &value);                 \
                                                                         \
-                *field = name##_from_string(value);                     \
+                f = name##_from_string(value);                          \
+                if (f < 0)                                              \
+                        return f;                                       \
                                                                         \
+                *field = f;                                             \
                 return 0;                                               \
         }