[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] [PATCH] Make evutil_read_file() close-on-exec safe.



On 12/02/2012 04:21, Nick Mathewson wrote:
> On Sat, Feb 11, 2012 at 3:15 PM, Ross Lagerwall <rosslagerwall@xxxxxxxxx> wrote:
>> If we can't trust the compile-time value and we can't detect the runtime
>> behavior then I think the solution I suggested is a reasonable idea.
> 
> Agreed.
> 
> (Actually, we _could_ detect it at runtime by using fcntl(F_GETFD) on
> an fd after we opened it with O_CLOEXEC.  But that would throw away
> the syscall that we just saved.)
> 
>>> Additionally, I see 3 other open()s: two in arc4random.c and one in
>>> devpoll.c.  Maybe this means we want an evutil_* wrapper function to
>>> set CLOEXEC on fds.
>>>
>>> thoughts?
>>
>> Attached is a patch which provides a new utility function,
>> evutil_open_closeonexec which is used instead in place of the various
>> open() calls.
> 
> Looks good.  I'm merging it onto patches-2.0, with a couple of tweaks:
> 
>   * Windows doesn't have mode_t so far as I can tell, so I'm using
> "unsigned" instead.
>   * I'm not passing the third argument to open unless the O_CREAT flag
> was provided; I seem to recall that using the three-argument form
> without O_CREAT can confuse some  unixes.
> 
> cheers,

Thanks

Ross

Attachment: signature.asc
Description: OpenPGP digital signature