mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 16:35:28 +00:00
Noux: fix resetting fds in unmarshal_fds
Since FD_ZERO() resets a whole fd_set (which is 128 bytes) using it to reset dst_fds will override otherwise used memory if the memory was allocated dynamically and is less than sizeof (fd_set). So instead of using this macro we reset the fd_set manually.
This commit is contained in:
parent
0539c7180b
commit
db9dc3388d
@ -241,7 +241,15 @@ static void unmarshal_fds(int *src_fds, size_t src_fds_len, fd_set *dst_fds)
|
||||
{
|
||||
if (!dst_fds) return;
|
||||
|
||||
FD_ZERO(dst_fds);
|
||||
/**
|
||||
* Calling FD_ZERO will not work because it will try to reset sizeof (fd_set)
|
||||
* which is typically 128 bytes but dst_fds might by even less bytes large if
|
||||
* it was allocated dynamically. So we will reset the fd_set manually which
|
||||
* will work fine as long as we are using FreeBSDs libc - another libc however
|
||||
* might use a different struct.
|
||||
*/
|
||||
for (size_t i = 0; i < src_fds_len; i++)
|
||||
dst_fds->__fds_bits[i] = 0;
|
||||
|
||||
for (size_t i = 0; i < src_fds_len; i++)
|
||||
FD_SET(src_fds[i], dst_fds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user