summaryrefslogtreecommitdiffstats
path: root/server/nss/nsssrv_dp.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-02-24 16:36:16 -0500
committerSimo Sorce <idra@samba.org>2009-02-24 16:50:08 -0500
commit57df88bb0b4ce656855410a8c2969d93475c2f11 (patch)
tree644bf0ce008c446efc27cf369d18a248da5ae7b4 /server/nss/nsssrv_dp.c
parent3621d86ad205dcacb50022f8e6b669218600257f (diff)
downloadsssd-57df88bb0b4ce656855410a8c2969d93475c2f11.tar.gz
sssd-57df88bb0b4ce656855410a8c2969d93475c2f11.tar.xz
sssd-57df88bb0b4ce656855410a8c2969d93475c2f11.zip
Proper fix for memory handling problem.
sbus_message_handler is not responsible anymore for sending back data in any case. Transfer this responsibility to the handler function called. This way both synchronous and asynchronous funstions use the interface the same way and can properly free memory referenced by the reply after the send buffer has been filled in and all copies are done in sbus_conn_send_reply()
Diffstat (limited to 'server/nss/nsssrv_dp.c')
-rw-r--r--server/nss/nsssrv_dp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/nss/nsssrv_dp.c b/server/nss/nsssrv_dp.c
index 487ac285d..ec8aea8b1 100644
--- a/server/nss/nsssrv_dp.c
+++ b/server/nss/nsssrv_dp.c
@@ -101,7 +101,6 @@ int nss_dp_send_acct_req(struct nss_ctx *nctx, TALLOC_CTX *memctx,
DBusMessage *msg;
DBusPendingCall *pending_reply;
DBusConnection *conn;
- DBusError dbus_error;
dbus_bool_t ret;
uint32_t be_type;
const char *attrs = "core";
@@ -144,7 +143,6 @@ int nss_dp_send_acct_req(struct nss_ctx *nctx, TALLOC_CTX *memctx,
}
conn = sbus_get_connection(nctx->dp_ctx->scon_ctx);
- dbus_error_init(&dbus_error);
/* create the message */
msg = dbus_message_new_method_call(NULL,
@@ -248,6 +246,7 @@ static int nss_dp_get_reply(DBusPendingCall *pending,
if (!ret) {
DEBUG(1,("Filed to parse message\n"));
/* FIXME: Destroy this connection ? */
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
err = EIO;
goto done;
}
@@ -281,7 +280,7 @@ done:
return err;
}
-static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r)
+static int nss_dp_identity(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
dbus_uint16_t clitype = DP_CLI_FRONTEND;
@@ -294,6 +293,8 @@ static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r)
clitype, version, cliname));
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
+
ret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &clitype,
DBUS_TYPE_UINT16, &version,
@@ -301,10 +302,14 @@ static int nss_dp_identity(DBusMessage *message, void *data, DBusMessage **r)
DBUS_TYPE_STRING, &nullname,
DBUS_TYPE_INVALID);
if (!ret) {
+ dbus_message_unref(reply);
return EIO;
}
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}