Skip to content

Commit

Permalink
Print a warning in CHANcreate, not returning NULL
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Julien-Elie committed Jul 9, 2023
1 parent 69ee8b6 commit 28d93e3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions innd/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 28d93e3

Please sign in to comment.