From 7a5793c44d6619096c7c90020b08a5bb12d343ba Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 19 Mar 2018 13:38:28 +1100 Subject: [PATCH 1/2] ctdb-client: Do not try to allocate 0 sized record BUG: https://bugzilla.samba.org/show_bug.cgi?id=13356 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 92a68af1a8473dc2a5d9d6036830f944e968606d) --- ctdb/client/client_db.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index e86830e7bfb..a0c4cfed652 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -1413,14 +1413,19 @@ struct ctdb_record_handle *ctdb_fetch_lock_recv(struct tevent_req *req, offset = ctdb_ltdb_header_len(&h->header); data->dsize = h->data.dsize - offset; - data->dptr = talloc_memdup(mem_ctx, h->data.dptr + offset, - data->dsize); - if (data->dptr == NULL) { - TALLOC_FREE(state->h); - if (perr != NULL) { - *perr = ENOMEM; + if (data->dsize == 0) { + data->dptr = NULL; + } else { + data->dptr = talloc_memdup(mem_ctx, + h->data.dptr + offset, + data->dsize); + if (data->dptr == NULL) { + TALLOC_FREE(state->h); + if (perr != NULL) { + *perr = ENOMEM; + } + return NULL; } - return NULL; } } -- 2.14.3 From 468a8f3c00075bfe7427373c3c46ac6748ea29d1 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 19 Mar 2018 13:58:43 +1100 Subject: [PATCH 2/2] ctdb-client: Add missing initialization of tevent_context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13356 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 4e37be92bfb790150b3791bef552aa4acf8f78b7) --- ctdb/client/client_db.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index a0c4cfed652..c0ecdeb2d30 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -1191,6 +1191,7 @@ struct tevent_req *ctdb_fetch_lock_send(TALLOC_CTX *mem_ctx, if (tevent_req_nomem(state->h, req)) { return tevent_req_post(req, ev); } + state->h->ev = ev; state->h->client = client; state->h->db = db; state->h->key.dptr = talloc_memdup(state->h, key.dptr, key.dsize); -- 2.14.3