diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-02-23 15:43:31 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2009-02-23 16:20:52 -0500 |
commit | 13421cbe0af4343f9d110600755ffa756690b282 (patch) | |
tree | fab749d3fd49148ec62d7d664c933fb40b36d9a9 /server/nss/nsssrv_dp.c | |
parent | f8469b71247b5a41cfdf0f54c25ceda1552e0ee9 (diff) | |
download | sssd-13421cbe0af4343f9d110600755ffa756690b282.tar.gz sssd-13421cbe0af4343f9d110600755ffa756690b282.tar.xz sssd-13421cbe0af4343f9d110600755ffa756690b282.zip |
Fixing serious memory allocation bug in sbus_message_handler.
dbus_message_append_args() adds a reference to memory that is not
copied to the outgoing message until dbus_connection_send() is
called. Since we compile our reply messages in functions and then
return the reply, we need a mechanism for deleting allocated
memory after invoking dbus_connection_send. I have changed the
arguments to sbus_msg_handler_fn so that it takes a talloc ctx
containing the sbus_message_handler_ctx and a pointer to a reply
object. We can now allocate memory as a child of the reply context
and free it after calling dbus_connection_send.
Diffstat (limited to 'server/nss/nsssrv_dp.c')
-rw-r--r-- | server/nss/nsssrv_dp.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/server/nss/nsssrv_dp.c b/server/nss/nsssrv_dp.c index 487ac285d..b5746e869 100644 --- a/server/nss/nsssrv_dp.c +++ b/server/nss/nsssrv_dp.c @@ -281,20 +281,19 @@ done: return err; } -static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r) +static int nss_dp_identity(DBusMessage *message, struct sbus_message_ctx *reply) { dbus_uint16_t version = DATA_PROVIDER_VERSION; dbus_uint16_t clitype = DP_CLI_FRONTEND; const char *cliname = "NSS"; const char *nullname = ""; - DBusMessage *reply; dbus_bool_t ret; DEBUG(4,("Sending ID reply: (%d,%d,%s)\n", clitype, version, cliname)); - reply = dbus_message_new_method_return(message); - ret = dbus_message_append_args(reply, + reply->reply_message = dbus_message_new_method_return(message); + ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_UINT16, &clitype, DBUS_TYPE_UINT16, &version, DBUS_TYPE_STRING, &cliname, @@ -304,7 +303,6 @@ static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r) return EIO; } - *r = reply; return EOK; } |