about summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getaddrinfo.c29
-rw-r--r--sysdeps/posix/system.c34
2 files changed, 38 insertions, 25 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 4d32ee02ac..f819bb4c0c 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -45,7 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* getaddrinfo() v1.13 */
 
 /* To do what POSIX says, even when it's broken: */
-/* #define BROKEN_LIKE_POSIX 1 */
+#define BROKEN_LIKE_POSIX 1
 #define LOCAL 1
 #define INET6 1
 #define HOSTTABLE 0
@@ -168,21 +168,34 @@ static int gaih_local(const char *name, const struct gaih_service *service,
 };
 #endif /* LOCAL */
 
-static struct gaih_typeproto gaih_inet_typeproto[] = {
+static struct gaih_typeproto gaih_inet_typeproto[] =
+{
   { 0, 0, NULL },
-  { SOCK_STREAM, IPPROTO_TCP, (char *)"tcp" },
-  { SOCK_DGRAM, IPPROTO_UDP, (char *)"udp" },
+  { SOCK_STREAM, IPPROTO_TCP, (char *) "tcp" },
+  { SOCK_DGRAM, IPPROTO_UDP, (char *) "udp" },
   { 0, 0, NULL }
 };
 
 static int gaih_inet_serv(char *servicename, struct gaih_typeproto *tp, struct gaih_servtuple **st)
 {
   struct servent *s;
+  int tmpbuflen = 1024;
+  struct servent ts;
+  char *tmpbuf = __alloca (tmpbuflen);
+  while (__getservbyname_r (servicename, tp->name, &ts, tmpbuf, tmpbuflen, &s))
+    {
+      if (errno == ERANGE)
+	{
+	  tmpbuflen *= 2;
+	  tmpbuf = __alloca (tmpbuflen);
+	}
+      else
+	{
+	  return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+	}
+    }
 
-  if (!(s = getservbyname(servicename, tp->name)))
-    return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
-
-  if (!(*st = malloc(sizeof(struct gaih_servtuple))))
+  if (!(*st = malloc (sizeof (struct gaih_servtuple))))
     return -EAI_MEMORY;
 
   (*st)->next = NULL;
diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
index b1a685c29a..2b8f9cb590 100644
--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <stddef.h>
 #include <stdlib.h>