diff options
author | Pauli <paul.dale@oracle.com> | 2019-08-24 16:13:24 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-08-24 16:40:34 +1000 |
commit | e1f8584d47a499301fba781086af6885fcf21fec (patch) | |
tree | c697782f488bc43ae2d2359c2e92e73675a20989 /crypto | |
parent | f42c225d7f9a0bce0bf46103343402d3f0ad742f (diff) |
Avoid overflowing FDSET when using select(2).
There is a problem in the rand_unix.c code when the random seed fd is greater
than or equal to FD_SETSIZE and the FDSET overruns its limit and walks the
stack.
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/9686)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rand/rand_unix.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 0ca66e41ff..7e20fa29c6 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -390,7 +390,7 @@ static int wait_random_seeded(void) } /* Open /dev/random and wait for it to be readable */ if ((fd = open(DEVRANDOM_WAIT, O_RDONLY)) != -1) { - if (DEVRANDM_WAIT_USE_SELECT) { + if (DEVRANDM_WAIT_USE_SELECT && fd < FD_SETSIZE) { FD_ZERO(&fds); FD_SET(fd, &fds); while ((r = select(fd + 1, &fds, NULL, NULL, NULL)) < 0 |