aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/net.cc22
2 files changed, 18 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index a8bfcf7..24ef866 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* exceptions.cc: Make windows_system_directory non-static.
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index baa96bb..4e65bfa 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -936,17 +936,19 @@ cygwin_gethostname (char *name, size_t len)
extern "C" struct hostent *
cygwin_gethostbyname (const char *name)
{
- static unsigned char tmp_addr[4];
- static struct hostent tmp;
- static char *tmp_aliases[1];
- static char *tmp_addr_list[2];
- static int a, b, c, d;
+ unsigned char tmp_addr[4];
+ struct hostent tmp, *h;
+ char *tmp_aliases[1] = {0};
+ char *tmp_addr_list[2] = {0,0};
+ unsigned int a, b, c, d;
+ char dummy;
sig_dispatch_pending ();
if (check_null_str_errno (name))
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 */
memset (&tmp, 0, sizeof (tmp));
@@ -960,11 +962,13 @@ cygwin_gethostbyname (const char *name)
tmp.h_addrtype = 2;
tmp.h_length = 4;
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)
{
debug_printf ("name %s", name);