fd_set is (typically) defined as an 1024 bit long array.
Therefore, using FD_SET with an fd > 1024 will result in a buffer
overrun.
Reported-by: Coverity Scan
CID
1360535 (#1 of 1): Out-of-bounds write (OVERRUN)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
*/
void pselect_fd_too_big(void)
{
- fd_set rfds;
+ long rfds[2048 / (sizeof(long) * CHAR_BIT)];
int ret;
int fd2;
char buf[BUF_SIZE];
return;
}
FD_ZERO(&rfds);
- FD_SET(fd2, &rfds);
-
+ FD_SET(fd2, (fd_set *) &rfds);
ret = syscall(SYS_pselect6, fd2 + 1, &rfds, NULL, NULL, NULL, NULL);
if (ret == -1) {