X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fhostname%2Fhostnamed.c;h=cd3ef491ac3ec4fb9efae6d3ab78c7904de3abd0;hb=b5cff06b4876e9e3c30431f642b9e54a17bca19a;hp=7dab5f40df14a7db591a655e6afa36a5ac52a87c;hpb=669241a076108e0483d7d8475beaa506106d077e;p=elogind.git diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 7dab5f40d..cd3ef491a 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -451,6 +451,14 @@ static DBusHandlerResult hostname_message_handler( } else { char *h; + /* The icon name might ultimately be + * used as file name, so better be + * safe than sorry */ + if (k == PROP_ICON_NAME && !filename_is_safe(name)) + return bus_send_error_reply(connection, message, NULL, -EINVAL); + if (k == PROP_PRETTY_HOSTNAME && !string_is_safe(name)) + return bus_send_error_reply(connection, message, NULL, -EINVAL); + h = strdup(name); if (!h) goto oom; @@ -532,8 +540,7 @@ static int connect_bus(DBusConnection **_bus) { if (!dbus_connection_register_object_path(bus, "/org/freedesktop/hostname1", &hostname_vtable, NULL) || !dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) { - log_error("Out of memory."); - r = -ENOMEM; + r = log_oom(); goto fail; }