From 9173ae5f7f02d2f1675d505ee3da7e62cceeafd0 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Tue, 3 Sep 2019 15:26:19 +0200 Subject: s3/lib/ctdbd_conn: assert hdr following read/recv 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 Signed-off-by: David Disseldorp Reviewed-by: Noel Power Autobuild-User(master): Noel Power Autobuild-Date(master): Wed Sep 4 14:20:16 UTC 2019 on sn-devel-184 --- source3/lib/ctdbd_conn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/lib/ctdbd_conn.c') diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 8a8fbec4552..843e57287b6 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -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"); -- cgit v1.2.1