sim-se: add checks in selectFunc to fix up crashes
In selectFunc, FD_ZERO are invoked without checking whether reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds) is NULL. So does writefds and errorfds. Change-Id: I175fe1369c85fd8a832a227c3f90f25d772f33e1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53143 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -2543,9 +2543,15 @@ selectFunc(SyscallDesc *desc, ThreadContext *tc, int nfds,
|
||||
if (retval == -1)
|
||||
return -errno;
|
||||
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds));
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)writefds));
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)errorfds));
|
||||
if (readfds) {
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)readfds));
|
||||
}
|
||||
if (writefds) {
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)writefds));
|
||||
}
|
||||
if (errorfds) {
|
||||
FD_ZERO(reinterpret_cast<fd_set *>((typename OS::fd_set *)errorfds));
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to translate the host file descriptor set into a target file
|
||||
|
||||
Reference in New Issue
Block a user