From 22299f9898ddb84db47b5372ca3cd49c3ec4a1f5 Mon Sep 17 00:00:00 2001 From: Swen Schillig Date: Tue, 13 Mar 2018 09:06:45 +0100 Subject: [PATCH] ctdb: Fixing possible memory leak in ctdb_daemon_read_cb In case of an error condition the further processing of the data is cancelled and the callback returns. In such a scenario the data has to be free'd. Signed-off-by: Swen Schillig Reviewed-by: Martin Schwenke Reviewed-by: Jeremy Allison --- ctdb/server/ctdb_daemon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 7665e2a29c3..6d2f70f99b6 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -903,12 +903,12 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args) if (hdr->ctdb_magic != CTDB_MAGIC) { ctdb_set_error(client->ctdb, "Non CTDB packet rejected\n"); - return; + goto err_out; } if (hdr->ctdb_version != CTDB_PROTOCOL) { ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version); - return; + goto err_out; } DEBUG(DEBUG_DEBUG,(__location__ " client request %u of type %u length %u from " @@ -917,6 +917,10 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args) /* it is the responsibility of the incoming packet function to free 'data' */ daemon_incoming_packet(client, hdr); + return; + +err_out: + TALLOC_FREE(data); } -- 2.11.4.GIT