Skip to content

Commit

Permalink
Fix #919, check index inside fdset conversions
Browse files Browse the repository at this point in the history
Add an extra limit check for the index, as it is possible
due to padding that this goes beyond the end of the array.
  • Loading branch information
jphickey committed Mar 22, 2021
1 parent ead5723 commit cdd57c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/os/portable/os-impl-bsd-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ static int OS_FdSet_ConvertIn_Impl(fd_set *os_set, OS_FdSet *OSAL_set)
bit = 0;
while (objids != 0)
{
if (objids & 0x01)
id = OSAL_INDEX_C((offset * 8) + bit);
if ((objids & 0x01) != 0 && id < OS_MAX_NUM_OPEN_FILES)
{
id = OSAL_INDEX_C((offset * 8) + bit);
osfd = OS_impl_filehandle_table[id].fd;
if (osfd >= 0 && OS_impl_filehandle_table[id].selectable)
{
Expand Down Expand Up @@ -134,9 +134,9 @@ static void OS_FdSet_ConvertOut_Impl(fd_set *output, OS_FdSet *Input)
bit = 0;
while (objids != 0)
{
if (objids & 0x01)
id = OSAL_INDEX_C((offset * 8) + bit);
if ((objids & 0x01) != 0 && id < OS_MAX_NUM_OPEN_FILES)
{
id = OSAL_INDEX_C((offset * 8) + bit);
osfd = OS_impl_filehandle_table[id].fd;
if (osfd < 0 || !FD_ISSET(osfd, output))
{
Expand Down

0 comments on commit cdd57c7

Please sign in to comment.