aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/net.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-02-07 15:27:40 +0000
committerChristopher Faylor <me@cgf.cx>2005-02-07 15:27:40 +0000
commita694f07970127dc45906a9d35ae2d1f588450e1d (patch)
tree7d83463fca75875a1818d8037b5d650434e72ef1 /winsup/cygwin/net.cc
parentbec2abd71e3a582cb2727f1246827ab4b2978415 (diff)
downloadnewlib-a694f07970127dc45906a9d35ae2d1f588450e1d.zip
newlib-a694f07970127dc45906a9d35ae2d1f588450e1d.tar.gz
newlib-a694f07970127dc45906a9d35ae2d1f588450e1d.tar.bz2
* net.cc (cygwin_gethostbyname): Be more picky about what's a numeric address
string, and use tls in that case too.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc22
1 files changed, 13 insertions, 9 deletions
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);