[patch] dup_ent does not set dst when src is NULL
Christopher Faylor
cgf-no-personal-reply-please@cygwin.com
Wed Apr 6 05:51:00 GMT 2005
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
More information about the Cygwin-patches
mailing list