Skip to contentSkip to conversation

monitor: Call FD_ISSET with valid descriptors only

PATCH New Phil Sutter 1 participant 1 message Feb 26 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 monitor: Call FD_ISSET with valid descriptors only

This fixes for 'nft monitor' aborting with:

*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminated

It appears FD_ISSET is not tolerating invalid fd values (-1 in this case).

Fixes 868040f892238 ("configure: Implement --enable-profiling option")
---
 src/mnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/mnl.c +1 -1
index 3f3ef82a25cb5..2e7ae74434094 100644
@@ -2410,7 +2410,7 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
 		if (ret < 0)
 			return -1;
 
-		if (FD_ISSET(sigfd, &readfds))
+		if (sigfd != -1 && FD_ISSET(sigfd, &readfds))
 			check_signalfd(sigfd);
 
 		if (FD_ISSET(fd, &readfds)) {
Signature · 1 line
2.51.0