ctdbd_conn: possible memleak in ctdbd_db_attach
authorSwen Schillig <swen@linux.ibm.com>
Mon, 30 Mar 2020 10:34:12 +0000 (12:34 +0200)
committerMartin Schwenke <martins@samba.org>
Thu, 2 Apr 2020 09:51:39 +0000 (09:51 +0000)
A cstatus != 0 or a data.dsize != sizeof(uint32_t)
does not guarantee to have no received data referenced by data.dptr.
Therefore, make sure data.dptr is free'd.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
source3/lib/ctdbd_conn.c

index 33c811a06b7a819212300d7493bca9a10c766996..e968ec5e49125c57a57172294736317b1d35d486 100644 (file)
@@ -847,7 +847,7 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
                    const char *name, uint32_t *db_id, bool persistent)
 {
        int ret;
-       TDB_DATA data;
+       TDB_DATA data = {0};
        int32_t cstatus;
 
        data = string_term_tdb_data(name);
@@ -865,6 +865,7 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
 
        if (cstatus != 0 || data.dsize != sizeof(uint32_t)) {
                DEBUG(0,(__location__ " ctdb_control for db_attach failed\n"));
+               TALLOC_FREE(data.dptr);
                return EIO;
        }