* net.cc (cygwin_gethostbyname): Be more picky about what's a numeric address
string, and use tls in that case too.
This commit is contained in:
parent
bec2abd71e
commit
a694f07970
|
@ -1,3 +1,8 @@
|
||||||
|
2005-02-06 Yitzchak Scott-Thoennes <sthoenna@efn.org>
|
||||||
|
|
||||||
|
* net.cc (cygwin_gethostbyname): Be more picky about what's a numeric
|
||||||
|
address string, and use tls in that case too.
|
||||||
|
|
||||||
2005-02-07 Christopher Faylor <cgf@timesys.com>
|
2005-02-07 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* exceptions.cc: Make windows_system_directory non-static.
|
* exceptions.cc: Make windows_system_directory non-static.
|
||||||
|
|
|
@ -936,17 +936,19 @@ cygwin_gethostname (char *name, size_t len)
|
||||||
extern "C" struct hostent *
|
extern "C" struct hostent *
|
||||||
cygwin_gethostbyname (const char *name)
|
cygwin_gethostbyname (const char *name)
|
||||||
{
|
{
|
||||||
static unsigned char tmp_addr[4];
|
unsigned char tmp_addr[4];
|
||||||
static struct hostent tmp;
|
struct hostent tmp, *h;
|
||||||
static char *tmp_aliases[1];
|
char *tmp_aliases[1] = {0};
|
||||||
static char *tmp_addr_list[2];
|
char *tmp_addr_list[2] = {0,0};
|
||||||
static int a, b, c, d;
|
unsigned int a, b, c, d;
|
||||||
|
char dummy;
|
||||||
|
|
||||||
sig_dispatch_pending ();
|
sig_dispatch_pending ();
|
||||||
if (check_null_str_errno (name))
|
if (check_null_str_errno (name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
|
if (sscanf (name, "%u.%u.%u.%u%c", &a, &b, &c, &d, &dummy) == 4
|
||||||
|
&& a < 256 && b < 256 && c < 256 && d < 256)
|
||||||
{
|
{
|
||||||
/* In case you don't have DNS, at least x.x.x.x still works */
|
/* In case you don't have DNS, at least x.x.x.x still works */
|
||||||
memset (&tmp, 0, sizeof (tmp));
|
memset (&tmp, 0, sizeof (tmp));
|
||||||
|
@ -960,11 +962,13 @@ cygwin_gethostbyname (const char *name)
|
||||||
tmp.h_addrtype = 2;
|
tmp.h_addrtype = 2;
|
||||||
tmp.h_length = 4;
|
tmp.h_length = 4;
|
||||||
tmp.h_addr_list = tmp_addr_list;
|
tmp.h_addr_list = tmp_addr_list;
|
||||||
return &tmp;
|
h = &tmp;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
h = gethostbyname (name);
|
||||||
|
|
||||||
|
_my_tls.locals.hostent_buf = (hostent *) dup_ent (_my_tls.locals.hostent_buf, h, is_hostent);
|
||||||
|
|
||||||
_my_tls.locals.hostent_buf = (hostent *) dup_ent (_my_tls.locals.hostent_buf, gethostbyname (name),
|
|
||||||
is_hostent);
|
|
||||||
if (!_my_tls.locals.hostent_buf)
|
if (!_my_tls.locals.hostent_buf)
|
||||||
{
|
{
|
||||||
debug_printf ("name %s", name);
|
debug_printf ("name %s", name);
|
||||||
|
|
Loading…
Reference in New Issue