From: Lennart Poettering Date: Thu, 3 May 2012 21:06:19 +0000 (+0200) Subject: dbus: handle invalid enum values better X-Git-Tag: v183~164 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e476bc9d18c706564d797882df6a27ab2d45b8b;p=systemd dbus: handle invalid enum values better --- diff --git a/src/shared/dbus-common.h b/src/shared/dbus-common.h index 85981290..edb81073 100644 --- a/src/shared/dbus-common.h +++ b/src/shared/dbus-common.h @@ -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; \ }