This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: [patch] dup_ent does not set dst when src is NULL
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Wed, 6 Apr 2005 01:51:16 -0400
- Subject: Re: [patch] dup_ent does not set dst when src is NULL
- References: <4253768A.8711D94@dessent.net>
- Reply-to: cygwin-patches at cygwin dot com
On Tue, Apr 05, 2005 at 10:41:30PM -0700, Brian Dessent wrote:
>In net.cc, there are several cases where dup_ent() is used as follows:
>
>dup_ent (servent_buf, getservbyname (name, proto), t_servent);
>syscall_printf ("%p = getservbyname (%s, %s)",
> _my_tls.locals.servent_buf, name, proto);
>return _my_tls.locals.servent_buf;
>
>This presents a problem if getservbyname() returns NULL, because
>dup_ent just returns NULL, it does not modify 'dst'. This results in
>the function returning the previous successful value if the
>get_foo_by_bar() function returned NULL. This seems to be applicable to
>getservbyname(), getservbyport(), gethostbyaddr(), and gethostbyname().
>
>In the case of gethostbyname() there's also another bug in that there
>will be a spurious debug_printf() about dup_ent failing if the address
>simply didn't resolve. That should probably be fixed too but I wanted
>to be sure the patch stayed "trivial".
Thanks for the patch, but I went out of my way to avoid freeing the
buffer when I maded changes to dup_ent a couple of weeks ago. I don't
want to revert to doing that again, so I've just used the return value
in all cases.
cgf