File 0888-epmd-Validate-that-the-FD-fits-in-the-set.patch of Package erlang

From ffb26e566c0cfc963883bb3e846e68d7a7c71cb0 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Thu, 16 Apr 2020 17:29:42 +0200
Subject: [PATCH 3/3] epmd: Validate that the FD fits in the set

On some OSs (NetBSD) we get larger FDs then we should based on the
number of files open to we have to check that the FD actually
fits in the fd_set.
---
 erts/epmd/src/epmd_srv.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c
index 2f4f189bb4..c37ca197f5 100644
--- a/erts/epmd/src/epmd_srv.c
+++ b/erts/epmd/src/epmd_srv.c
@@ -1050,6 +1050,12 @@ static int conn_open(EpmdVars *g,int fd)
   }
 #endif
 
+  if (fd >= FD_SETSIZE) {
+      dbg_tty_printf(g,0,"fd does not fit in fd_set fd=%d, FD_SETSIZE=%d",fd, FD_SETSIZE);
+      close(fd);
+      return EPMD_FALSE;
+  }
+
   for (i = 0; i < g->max_conn; i++) {
     if (g->conn[i].open == EPMD_FALSE) {
       g->active_conn++;
-- 
2.16.4

openSUSE Build Service is sponsored by