From: Swen Schillig Date: Tue, 13 Mar 2018 08:06:45 +0000 (+0100) Subject: ctdb: Fixing possible memory leak in ctdb_daemon_read_cb X-Git-Tag: talloc-2.1.13~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22299f9898ddb84db47b5372ca3cd49c3ec4a1f5;p=thirdparty%2Fsamba.git 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 --- 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); }