From 830174c7b52181705dca44cd2fae4a8baa5f6111 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 20 Nov 2023 15:30:28 +0100 Subject: [PATCH] Fixed possible buffer underflow. Signed-off-by: Toni Uhlig --- dependencies/nDPIsrvd.h | 2 +- nDPIsrvd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dependencies/nDPIsrvd.h b/dependencies/nDPIsrvd.h index 9e64260d4..6623758d6 100644 --- a/dependencies/nDPIsrvd.h +++ b/dependencies/nDPIsrvd.h @@ -702,7 +702,7 @@ static inline int nDPIsrvd_setup_address(struct nDPIsrvd_address * const address } if (destination[0] == '[') { - if (last_colon > destination && *(last_colon - 1) != ']') + if (last_colon - destination > 1 && *(last_colon - 1) != ']') { return 1; } diff --git a/nDPIsrvd.c b/nDPIsrvd.c index dd539fd73..83191e539 100644 --- a/nDPIsrvd.c +++ b/nDPIsrvd.c @@ -1516,8 +1516,8 @@ static int mainloop(struct nio * const io) static int setup_event_queue(struct nio * const io) { #ifdef ENABLE_EPOLL - if ((nDPIsrvd_options.use_poll == 0 && nio_use_epoll(io, 32) != NIO_SUCCESS) - || (nDPIsrvd_options.use_poll != 0 && nio_use_poll(io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS)) + if ((nDPIsrvd_options.use_poll == 0 && nio_use_epoll(io, 32) != NIO_SUCCESS) || + (nDPIsrvd_options.use_poll != 0 && nio_use_poll(io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS)) #else if (nio_use_poll(io, nDPIsrvd_MAX_REMOTE_DESCRIPTORS) != NIO_SUCCESS) #endif