From: Andrew Tridgell Date: Thu, 3 May 2007 03:44:27 +0000 (+1000) Subject: don't zero beyond packet header unnecessarily X-Git-Tag: tevent-0.9.20~348^2~2790 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de0f848556894784276037973fc6488273defb7c;p=thirdparty%2Fsamba.git don't zero beyond packet header unnecessarily (This used to be ctdb commit 4cf88ca2ce81db8fe10b0dfedb81d99a2bd93328) --- diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index 5d619e0a907..55af203c581 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -727,7 +727,9 @@ struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb, { int size; struct ctdb_req_header *hdr; - size = ((length+1)+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1); + + length = MAX(length, slength); + size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1); hdr = (struct ctdb_req_header *)talloc_size(mem_ctx, size); if (hdr == NULL) { @@ -736,9 +738,9 @@ struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb, return NULL; } talloc_set_name_const(hdr, type); - memset(hdr, 0, size); + memset(hdr, 0, slength); + hdr->length = length; hdr->operation = operation; - hdr->length = size; hdr->ctdb_magic = CTDB_MAGIC; hdr->ctdb_version = CTDB_VERSION; hdr->srcnode = ctdb->vnn; @@ -761,7 +763,10 @@ struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb, { int size; struct ctdb_req_header *hdr; - size = ((length+1)+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1); + + length = MAX(length, slength); + size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1); + hdr = (struct ctdb_req_header *)ctdb->methods->allocate_pkt(mem_ctx, size); if (hdr == NULL) { DEBUG(0,("Unable to allocate transport packet for operation %u of length %u\n", @@ -769,9 +774,9 @@ struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb, return NULL; } talloc_set_name_const(hdr, type); - memset(hdr, 0, size); + memset(hdr, 0, slength); + hdr->length = length; hdr->operation = operation; - hdr->length = size; hdr->ctdb_magic = CTDB_MAGIC; hdr->ctdb_version = CTDB_VERSION; hdr->generation = ctdb->vnn_map->generation;