ctdb_req_control contains 4 padding bytes. Create an explicit pad variable here and...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 2 Jun 2010 06:49:05 +0000 (16:49 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 2 Jun 2010 06:49:05 +0000 (16:49 +1000)
PDUs are padded to 8 byte boundary. If padding is used, memset it to 0
to keep valgrind happy.

include/ctdb_protocol.h
libctdb/ctdb.c
libctdb/io_elem.c

index 2a334b9ff5aeac0e62471d320d2e4d7365404aa6..7a5d32de159d6b052dce478a19289672a7daa402 100644 (file)
@@ -410,6 +410,7 @@ struct ctdb_reply_getdbpath {
 struct ctdb_req_control {
        struct ctdb_req_header hdr;
        uint32_t opcode;
+       uint32_t pad;
        uint64_t srvid;
        uint32_t client_id;
 #define CTDB_CTRL_FLAG_NOREPLY   1
index 39f4bab2a2eb5fb06df3b49b0d285884a5024b80..8700a60dd4d207671c51431d44c3e1d7c7b15980 100644 (file)
@@ -354,6 +354,7 @@ struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
                                CTDB_REQ_CONTROL, destnode, new_reqid(ctdb));
 
        pkt = req->hdr.control;
+       pkt->pad = 0;
        pkt->opcode = opcode;
        pkt->srvid = 0;
        pkt->client_id = 0;
index ada77780575d27bca7a85512ea674006d77810ac..1a176988d1be4b155ed0c0bfc9ccae0d48ac6d50 100644 (file)
@@ -17,6 +17,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include <sys/types.h>
+#include <string.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <unistd.h>
@@ -34,6 +35,8 @@ struct io_elem {
 struct io_elem *new_io_elem(size_t len)
 {
        struct io_elem *elem;
+       size_t ask = len;
+
        len = (len + (CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
 
        elem = malloc(sizeof(*elem));
@@ -45,6 +48,10 @@ struct io_elem *new_io_elem(size_t len)
                return NULL;
        }
 
+       /* stamp out any padding to keep valgrind happy */
+       if (ask != len) {
+               memset(elem->data + ask, 0, len-ask);
+       }
        elem->len = len;
        elem->off = 0;
        return elem;