summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorShwetha Acharya <sacharya@redhat.com>2018-10-23 12:57:45 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-30 05:08:04 +0000
commit0c835893fdce59872103253985d152f4592eea89 (patch)
tree2f5faa10b212644ccde3ee0f840811d0d8eb5d17 /rpc
parentd7fa1a85b1d5213128ec1f58d1e22af2495b9a3e (diff)
rpc-transport/socket: NULL pointer dereferencing clang fix
Problem: ctx and res can be NULL. Solution: introduced a VALIDATE_OR_GOTO statement, hence removed the null check for ctx; added a check for res. Updates: bz#1622665 Change-Id: Ifee4c73e260530ab44c0a34c5ff5568f38f92c94 Signed-off-by: Shwetha Acharya <sacharya@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-transport/socket/src/name.c2
-rw-r--r--rpc/rpc-transport/socket/src/socket.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
index 39c0530b08e..3d3d108f135 100644
--- a/rpc/rpc-transport/socket/src/name.c
+++ b/rpc/rpc-transport/socket/src/name.c
@@ -413,7 +413,7 @@ af_inet_server_get_local_sockaddr(rpc_transport_t *this, struct sockaddr *addr,
}
}
- if (!(*addr_len)) {
+ if (!(*addr_len) && res) {
memcpy(addr, res->ai_addr, res->ai_addrlen);
*addr_len = res->ai_addrlen;
}
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 4368f3fcc1a..5887ee741f7 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2985,6 +2985,7 @@ socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in,
GF_VALIDATE_OR_GOTO("socket", this, out);
GF_VALIDATE_OR_GOTO("socket", this->private, out);
GF_VALIDATE_OR_GOTO("socket", this->xl, out);
+ GF_VALIDATE_OR_GOTO("socket", this->ctx, out);
THIS = this->xl;
priv = this->private;
@@ -3006,8 +3007,7 @@ socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in,
new_sock = sys_accept(priv->sock, SA(&new_sockaddr), &addrlen, aflags);
- if (ctx)
- event_handled(ctx->event_pool, fd, idx, gen);
+ event_handled(ctx->event_pool, fd, idx, gen);
if (new_sock == -1) {
gf_log(this->name, GF_LOG_WARNING, "accept on %d failed (%s)",