From d3b1456c52f7dc4f21cdae2855092fda6b96af4a Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 28 Aug 2018 00:01:26 +0530 Subject: clang-scan: fix multiple issues * Buffer overflow issue in glusterfsd * Null argument passed to function expecting non-null (event-epoll) * Make sure the op_ret value is set in macro (posix) Updates: bz#1622665 Change-Id: I32b378fc40a5e3ee800c0dfbc13335d44c9db9ac Signed-off-by: Amar Tumballi --- libglusterfs/src/event-epoll.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c index 8ff66a8445f..b144b77a11c 100644 --- a/libglusterfs/src/event-epoll.c +++ b/libglusterfs/src/event-epoll.c @@ -349,6 +349,11 @@ event_register_epoll (struct event_pool *event_pool, int fd, } slot = event_slot_get (event_pool, idx); + if (!slot) { + gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for fd=%d idx=%d", fd, idx); + return -1; + } assert (slot->fd == fd); @@ -413,6 +418,11 @@ event_unregister_epoll_common (struct event_pool *event_pool, int fd, goto out; slot = event_slot_get (event_pool, idx); + if (!slot) { + gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for fd=%d idx=%d", fd, idx); + return -1; + } assert (slot->fd == fd); @@ -477,6 +487,11 @@ event_select_on_epoll (struct event_pool *event_pool, int fd, int idx, GF_VALIDATE_OR_GOTO ("event", event_pool, out); slot = event_slot_get (event_pool, idx); + if (!slot) { + gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for fd=%d idx=%d", fd, idx); + return -1; + } assert (slot->fd == fd); @@ -544,6 +559,11 @@ event_dispatch_epoll_handler (struct event_pool *event_pool, gen = ev_data->gen; slot = event_slot_get (event_pool, idx); + if (!slot) { + gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for idx=%d", idx); + return -1; + } LOCK (&slot->lock); { @@ -902,6 +922,11 @@ event_handled_epoll (struct event_pool *event_pool, int fd, int idx, int gen) int ret = 0; slot = event_slot_get (event_pool, idx); + if (!slot) { + gf_msg ("epoll", GF_LOG_ERROR, 0, LG_MSG_SLOT_NOT_FOUND, + "could not find slot for fd=%d idx=%d", fd, idx); + return -1; + } assert (slot->fd == fd); -- cgit