From 28d93e34b92d322e00f22f539623fc5716dce289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20=C3=89LIE?= Date: Sun, 9 Jul 2023 14:43:32 +0200 Subject: [PATCH] Print a warning in CHANcreate, not returning NULL Let's play safe, and not return NULL when the file descriptor is too large. The rest of the code currently does not handle such a response, but ensures the file descriptor is valid before calling CHANcreate(). see #273 --- innd/chan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/innd/chan.c b/innd/chan.c index cf41fd39a..e5fa56934 100644 --- a/innd/chan.c +++ b/innd/chan.c @@ -186,11 +186,16 @@ CHANcreate(int fd, enum channel_type type, enum channel_state state, struct buffer out = {0, 0, 0, NULL}; /* Last time to ensure the file descriptor is not too high. Callers have - normally already handled that case. - Note that the channel table, created in CHANsetup, is known to have + normally already handled that case before and not called CHANcreate(). + Note that the channel table, created in CHANsetup(), is known to have enough room. */ - if (!isvalidfd(fd)) - return NULL; + if (!isvalidfd(fd)) { + /* Go on without returning NULL, in case a caller is not prepared to + receive such a response. */ + syswarn("%s file descriptor %d too high in CHANcreate (see " + "rlimitnofile in inn.conf)", + LogName, fd); + } /* Currently, we do no dynamic allocation, but instead assume that the channel table is sized large enough to hold all possible file