summaryrefslogtreecommitdiffstats
path: root/src/plugins/snort/daq_vpp.c
diff options
context:
space:
mode:
authorTianyu Li <tianyu.li@arm.com>2021-09-08 13:52:55 +0800
committerDamjan Marion <dmarion@me.com>2021-09-13 13:44:24 +0000
commit006bbc4945bc7df58c3e631f5626acb2555aa171 (patch)
tree222a6e3c0f80222d1c3a7ac8a4e2e2608cfca0bc /src/plugins/snort/daq_vpp.c
parent596c45b22211c9af243b624dc037f58c0aa1c302 (diff)
snort: fix epoll_wait unsigned return value
When epoll_wait return -1, access array epoll_events[i] out of bound and lead to segmentation fault. 1. Change return value to signed return value 2. Skip non fatal error e.g. EINTR Type: fix Signed-off-by: Tianyu Li <tianyu.li@arm.com> Change-Id: I4ece118999402ec6054baf0efb52419151655def
Diffstat (limited to 'src/plugins/snort/daq_vpp.c')
-rw-r--r--src/plugins/snort/daq_vpp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/snort/daq_vpp.c b/src/plugins/snort/daq_vpp.c
index 91bcb519e0e..e9d7523a986 100644
--- a/src/plugins/snort/daq_vpp.c
+++ b/src/plugins/snort/daq_vpp.c
@@ -562,7 +562,8 @@ vpp_daq_msg_receive (void *handle, const unsigned max_recv,
{
VPP_Context_t *vc = (VPP_Context_t *) handle;
uint32_t n_qpairs_left = vc->num_qpairs;
- uint32_t n, n_events, n_recv = 0;
+ uint32_t n, n_recv = 0;
+ int32_t n_events;
/* If the receive has been interrupted, break out of loop and return. */
if (vc->interrupted)
@@ -606,9 +607,14 @@ vpp_daq_msg_receive (void *handle, const unsigned max_recv,
n_events = epoll_wait (vc->epoll_fd, vc->epoll_events, vc->num_qpairs, 1000);
- if (n_events < 1)
+ if (n_events == 0)
{
- *rstat = n_events == -1 ? DAQ_RSTAT_ERROR : DAQ_RSTAT_TIMEOUT;
+ *rstat = DAQ_RSTAT_TIMEOUT;
+ return 0;
+ }
+ if (n_events < 0)
+ {
+ *rstat = errno == EINTR ? DAQ_RSTAT_TIMEOUT : DAQ_RSTAT_ERROR;
return 0;
}