summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2017-11-03 11:15:52 +0530
committerMohit Agrawal <moagrawa@redhat.com>2017-11-10 12:56:02 +0530
commit83558c69736878d2554ba77af3a6e27574da9447 (patch)
tree12501c5a90c05ca050a6487843ca65bee826bad1 /rpc
parent0f524f0710229a7f8de3a4e1e6a2790d40f67a8e (diff)
rpc: Fix several coverity issues in rpc/socket code
This patch fixes issues 287,289,286,809,690,276,401,402,403 from [1] [1] https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-10-30-9aa574a5/html/ BUG: 789278 Change-Id: I2716d07fbdab59f779c2852bde07756b0e9a4ddc Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 88901e75e98..fd793cdd50e 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -1655,12 +1655,14 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
frag->call_body.reply.accepted_success_state
= SP_STATE_READING_PROC_OPAQUE;
+ /* fall through */
case SP_STATE_READING_PROC_OPAQUE:
__socket_proto_read (priv, ret);
frag->call_body.reply.accepted_success_state
= SP_STATE_READ_PROC_OPAQUE;
+ /* fall through */
case SP_STATE_READ_PROC_OPAQUE:
read_proc_opaque:
@@ -1683,11 +1685,13 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this)
}
}
- iobref_add (in->iobref, iobuf);
+ ret = iobref_add (in->iobref, iobuf);
iobuf_unref (iobuf);
+ if (ret < 0) {
+ goto out;
+ }
in->payload_vector.iov_base = iobuf_ptr (iobuf);
-
in->payload_vector.iov_len = size;
}
@@ -2978,7 +2982,8 @@ socket_server_event_handler (int fd, int idx, int gen, void *data,
}
}
out:
- event_handled (ctx->event_pool, fd, idx, gen);
+ if (ctx)
+ event_handled (ctx->event_pool, fd, idx, gen);
if (cname && (cname != this->ssl_name)) {
GF_FREE(cname);
@@ -3206,8 +3211,8 @@ socket_connect (rpc_transport_t *this, int port)
* net.ipv6.bindv6only to 1 so that gluster services are
* avalable over IPv4 & IPv6.
*/
- int disable_v6only = 0;
-
+#ifdef IPV6_DEFAULT
+ int disable_v6only = 0;
if (setsockopt (priv->sock, IPPROTO_IPV6, IPV6_V6ONLY,
(void *)&disable_v6only,
sizeof (disable_v6only)) < 0) {
@@ -3215,6 +3220,7 @@ socket_connect (rpc_transport_t *this, int port)
"Error disabling sockopt IPV6_V6ONLY: \"%s\"",
strerror (errno));
}
+#endif
if (priv->nodelay && (sa_family != AF_UNIX)) {
ret = __socket_nodelay (priv->sock);
@@ -3778,14 +3784,13 @@ socket_getpeeraddr (rpc_transport_t *this, char *peeraddr, int addrlen,
GF_VALIDATE_OR_GOTO ("socket", this, out);
GF_VALIDATE_OR_GOTO ("socket", sa, out);
+ ret = 0;
*sa = this->peerinfo.sockaddr;
if (peeraddr != NULL) {
ret = socket_getpeername (this, peeraddr, addrlen);
}
- ret = 0;
-
out:
return ret;
}