[quagga-dev 16679] Re: bgpd: fix file descriptor leaks in vty_close

Evgeny Uskov eu at qrator.net
Mon Nov 27 12:48:38 GMT 2017


Hi,

Please note that vty_close has the following code:

  /* Close socket. */
  if (vty->fd > 0)
    close (vty->fd);
  else
    vty_stdio_reset ();

Condition that vty->fd is greater than zero in fact means vty->fd !=
STDIN_FILENO. I decided to use the same logic in the patch and use
numeric value 2 instead of STDERR_FILENO.

--
| Evgeny Uskov  | HLL l QRATOR
| mob.: +7 916 319 33 20
| skype: evgeny_uskov
| mailto: eu at qrator.net
| visit: www.qrator.net


On Sun, Nov 26, 2017 at 8:15 PM, Balaji Gurudoss <balajig81 at gmail.com> wrote:
> I think we should be good if we check wfd is greater than STDERR_FILENO &&
> also check if the vty->wfd if its not equal to vty->fd
>
>
>
> On Sun, Nov 26, 2017 at 10:34 PM, Nick Hilliard <nick at inex.ie> wrote:
>>
>> Balaji Gurudoss wrote:
>> > Can we use the macros(STDERR_FILENO/STDERR_FILENO) defined in uinstd.h
>> > for this so that its easier :)
>>
>> sure, but you'd need to check against STDIN_FILENO, STDOUT_FILENO and
>> STDERR_FILENO, which is a bit a mouthful.  Maybe a comment explaining
>> what's going on would be more useful?  It's not like any of the stdio
>> filenos are going to change any time soon.
>>
>> Nick
>>
>


More information about the Quagga-dev mailing list