From e7cbae70c89c8813918d9deb3895cb6886cdaeeb Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 31 Aug 2010 10:02:54 +0000 Subject: rpc-transport/socket: use xdr_sizeof instead of sizeof when trying to read vectored request/reply Signed-off-by: Raghavendra G Signed-off-by: Vijay Bellur BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875 --- rpc/rpc-transport/socket/src/socket.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'rpc/rpc-transport/socket') diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 26b56fad577..f7d4d8e40d0 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -37,10 +37,12 @@ /* ugly #includes below */ #include "protocol-common.h" #include "glusterfs3-xdr.h" +#include "glusterfs3.h" #include #include #include +#include #define GF_LOG_ERRNO(errno) ((errno == ENOTCONN) ? GF_LOG_DEBUG : GF_LOG_ERROR) #define SA(ptr) ((struct sockaddr *)ptr) @@ -737,6 +739,7 @@ __socket_read_vectored_request (rpc_transport_t *this) struct iobuf *iobuf = NULL; uint32_t remaining_size = 0; uint32_t gluster_write_proc_len = 0; + gfs3_write_req write_req = {0, }; if (!this || !this->private) goto out; @@ -773,7 +776,15 @@ __socket_read_vectored_request (rpc_transport_t *this) * here */ /* also read proc-header */ - gluster_write_proc_len = sizeof (gfs3_write_req); + gluster_write_proc_len = xdr_sizeof ((xdrproc_t) xdr_gfs3_write_req, + &write_req); + + if (gluster_write_proc_len == 0) { + gf_log (this->name, GF_LOG_DEBUG, + "xdr_sizeof on gfs3_write_req failed"); + ret = -1; + goto out; + } verflen = ntoh32 (*((uint32_t *)addr)) + gluster_write_proc_len; @@ -939,6 +950,7 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this) int ret = 0; struct iobuf *iobuf = NULL; uint32_t gluster_read_rsp_hdr_len = 0; + gfs3_read_rsp read_rsp = {0, }; if (!this || !this->private) goto out; @@ -948,8 +960,15 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this) switch (priv->incoming.frag.call_body.reply.accepted_success_state) { case SP_STATE_ACCEPTED_SUCCESS_REPLY_INIT: - gluster_read_rsp_hdr_len = sizeof (gfs3_read_rsp); + gluster_read_rsp_hdr_len = xdr_sizeof ((xdrproc_t) xdr_gfs3_read_rsp, + &read_rsp); + if (gluster_read_rsp_hdr_len == 0) { + gf_log (this->name, GF_LOG_DEBUG, + "xdr_sizeof on gfs3_read_rsp failed"); + ret = -1; + goto out; + } __socket_proto_init_pending (priv, gluster_read_rsp_hdr_len); priv->incoming.frag.call_body.reply.accepted_success_state -- cgit