]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib/ctdbd_conn: assert hdr following read/recv
authorDavid Disseldorp <ddiss@samba.org>
Tue, 3 Sep 2019 13:26:19 +0000 (15:26 +0200)
committerNoel Power <npower@samba.org>
Wed, 4 Sep 2019 14:20:16 +0000 (14:20 +0000)
ctdb_pkt_recv_recv() and ctdb_read_packet() give us a non-null hdr on
success, so drop the error path check in favour of an assert.

This fixes a regression in 3913b9a4088b83d6ed7f94d136a26ecfa7e16b35,
where tevent_req_error() may be skipped in the ctdbd_parse_done()
ctdb_pkt_recv_recv() error path.

Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Sep  4 14:20:16 UTC 2019 on sn-devel-184

source3/lib/ctdbd_conn.c

index 8a8fbec45524109cf05ae70e00f3e5c0f668bb0e..843e57287b6bdf08e63fe0a529e0639c6b6eb0de 100644 (file)
@@ -404,11 +404,12 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
  next_pkt:
 
        ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr);
-       if (hdr == NULL || ret != 0) {
+       if (ret != 0) {
                DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
                cluster_fatal("failed to read data from ctdbd\n");
                return -1;
        }
+       SMB_ASSERT(hdr != NULL);
 
        DEBUG(11, ("Received ctdb packet\n"));
        ctdb_packet_dump(hdr);
@@ -605,6 +606,7 @@ void ctdbd_socket_readable(struct tevent_context *ev,
                DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
                cluster_fatal("failed to read data from ctdbd\n");
        }
+       SMB_ASSERT(hdr != NULL);
 
        ret = ctdb_handle_message(ev, conn, hdr);
 
@@ -1086,6 +1088,7 @@ int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
                        DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
                        cluster_fatal("failed to read data from ctdbd\n");
                }
+               SMB_ASSERT(hdr != NULL);
 
                if (hdr->operation != CTDB_REQ_MESSAGE) {
                        DEBUG(0, ("Got operation %u, expected a message\n",
@@ -1946,10 +1949,11 @@ static void ctdbd_parse_done(struct tevent_req *subreq)
 
        ret = ctdb_pkt_recv_recv(subreq, state, &hdr);
        TALLOC_FREE(subreq);
-       if ((hdr == NULL) || tevent_req_error(req, ret)) {
+       if (tevent_req_error(req, ret)) {
                DBG_ERR("ctdb_pkt_recv_recv returned %s\n", strerror(ret));
                return;
        }
+       SMB_ASSERT(hdr != NULL);
 
        if (hdr->operation != CTDB_REPLY_CALL) {
                DBG_ERR("received invalid reply\n");