diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-26 22:52:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-27 21:58:07 +0100 |
commit | 64e96a194d9fb8e9e69769bf88f067fadf9acce7 (patch) | |
tree | efdecb42fa88671e5bfce82dcfc25e91e6770de0 /src/bus-proxyd | |
parent | networkd: fix kernel rtnl receive buffer overrun error (diff) | |
download | systemd-64e96a194d9fb8e9e69769bf88f067fadf9acce7.tar.xz systemd-64e96a194d9fb8e9e69769bf88f067fadf9acce7.zip |
bus-proxy: check passed parameter signature of all driver method calls
Diffstat (limited to 'src/bus-proxyd')
-rw-r--r-- | src/bus-proxyd/bus-proxyd.c | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index 32c8242221..4df2fb10af 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -543,14 +543,12 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic if (!streq_ptr(sd_bus_message_get_destination(m), "org.freedesktop.DBus")) return 0; - if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { - if (0 && !isempty(sd_bus_message_get_signature(m, true))) { - _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + /* The "Hello()" call is is handled in process_hello() */ - r = sd_bus_error_setf(&error, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters"); + if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { - return synthetic_reply_method_errno(m, r, &error); - } + if (!sd_bus_message_has_signature(m, "")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); return synthetic_reply_method_return(m, "s", "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" " @@ -640,6 +638,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "AddMatch")) { const char *match; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &match); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -653,6 +654,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "RemoveMatch")) { const char *match; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &match); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -669,6 +673,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = get_creds_by_message(a, m, SD_BUS_CREDS_SELINUX_CONTEXT, &creds, &error); if (r < 0) return synthetic_reply_method_errno(m, r, &error); @@ -679,6 +686,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = get_creds_by_message(a, m, SD_BUS_CREDS_PID, &creds, &error); if (r < 0) return synthetic_reply_method_errno(m, r, &error); @@ -689,6 +699,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = get_creds_by_message(a, m, SD_BUS_CREDS_UID, &creds, &error); if (r < 0) return synthetic_reply_method_errno(m, r, &error); @@ -699,6 +712,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic sd_id128_t server_id; char buf[SD_ID128_STRING_MAX]; + if (!sd_bus_message_has_signature(m, "")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_get_owner_id(a, &server_id); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -710,6 +726,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &name); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -723,11 +742,12 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic return synthetic_reply_method_return(m, "s", creds->unique_name); - /* "Hello" is handled in process_hello() */ - } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListActivatableNames")) { _cleanup_strv_free_ char **names = NULL; + if (!sd_bus_message_has_signature(m, "")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_list_names(a, NULL, &names); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -740,6 +760,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListNames")) { _cleanup_strv_free_ char **names = NULL; + if (!sd_bus_message_has_signature(m, "")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_list_names(a, &names, NULL); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -763,6 +786,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic char *arg0; int err = 0; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &arg0); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -821,6 +847,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "NameHasOwner")) { const char *name; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &name); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -837,6 +866,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReleaseName")) { const char *name; + if (!sd_bus_message_has_signature(m, "s")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "s", &name); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -858,6 +890,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReloadConfig")) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + if (!sd_bus_message_has_signature(m, "")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_error_setf(&error, SD_BUS_ERROR_NOT_SUPPORTED, "%s() is not supported", sd_bus_message_get_member(m)); return synthetic_reply_method_errno(m, r, &error); @@ -867,6 +902,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic uint32_t flags, param; bool in_queue; + if (!sd_bus_message_has_signature(m, "su")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "su", &name, &flags); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -910,6 +948,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic const char *name; uint32_t flags; + if (!sd_bus_message_has_signature(m, "su")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_read(m, "su", &name, &flags); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); @@ -943,6 +984,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic _cleanup_bus_message_unref_ sd_bus_message *msg = NULL; _cleanup_strv_free_ char **args = NULL; + if (!sd_bus_message_has_signature(m, "a{ss}")) + return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters")); + r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{ss}"); if (r < 0) return synthetic_reply_method_errno(m, r, NULL); |