select: Prevent negative index lookup on osmo_fd_lookup.table
Marked as WIP because I'm not entirely sure if negative index lookups
were allowed on purpose (although I doubt it)
Change-Id: Iba81873cbc435229599b1a8139cf4b627f8e6924
diff --git a/src/core/select.c b/src/core/select.c
index 69fa763..70047f0 100644
--- a/src/core/select.c
+++ b/src/core/select.c
@@ -522,7 +522,7 @@
* \returns \ref osmo_fd for \ref fd; NULL in case it doesn't exist */
struct osmo_fd *osmo_fd_get_by_fd(int fd)
{
- if (fd > maxfd)
+ if (fd > maxfd || fd < 0)
return NULL;
return osmo_fd_lookup.table[fd];
}