6 Apr 2005 07:41
[patch] dup_ent does not set dst when src is NULL
Brian Dessent <brian <at> dessent.net>
2005-04-06 05:41:30 GMT
2005-04-06 05:41:30 GMT
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".
A simple testcase that demonstrates the problem:
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
void mygetservbyname(char *serv, char *proto)
{
struct servent *p;
(Continue reading)
Corinna
RSS Feed