[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: port leak in select
From: |
Samuel Thibault |
Subject: |
Re: port leak in select |
Date: |
Fri, 2 Dec 2016 11:11:54 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Richard Braun, on Fri 02 Dec 2016 10:56:40 +0100, wrote:
> On Fri, Dec 02, 2016 at 10:43:04AM +0100, Samuel Thibault wrote:
> > Or simply
> >
> > (d[i].reply_port != MACH_PORT_NULL))
>
> Aren't there cases where an entry could remain uninitialized ?
Here, no, we have the same structure:
if (firstfd == -1)
/* But not if there were no ports to deal with at all.
We are just a pure timeout. */
portset = __mach_reply_port ();
else
{
portset = MACH_PORT_NULL;
for (i = firstfd; i <= lastfd; ++i)
+ if (d[i].type & SELECT_ERROR)
+ d[i].reply_port = MACH_PORT_NULL
+ else
- if (d[i].type & ~SELECT_ERROR)
{
int type = d[i].type;
d[i].reply_port = __mach_reply_port ();
if (timeout == NULL)
err = __io_select_request (d[i].io_port, d[i].reply_port, type);
else
and
if (firstfd != -1)
for (i = firstfd; i <= lastfd; ++i)
- if (d[i].type & ~(SELECT_ERROR | SELECT_RETURNED))
+ if (d[i].reply_port != MACH_PORT_NULL)
__mach_port_destroy (__mach_task_self (), d[i].reply_port);
Samuel