This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

one more resolv patch


I've appended an extended patch for the DNS NSS module.  This might
also be the reason for Martin's failure.  Please give it a try.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: Versions
===================================================================
RCS file: /glibc/cvsfiles/libc/resolv/Versions,v
retrieving revision 1.1
diff -u -r1.1 Versions
--- Versions	1998/07/02 22:32:29	1.1
+++ Versions	1999/02/03 02:02:40
@@ -42,6 +42,10 @@
     __res_send;
     __sym_ntop; __sym_ntos; __sym_ston;
   }
+  GLIBC_2.1 {
+    # Needed in libnss_dns.
+    __ns_name_unpack; __ns_name_ntop;
+  }
 }
 
 libnss_dns {
Index: res_comp.c
===================================================================
RCS file: /glibc/cvsfiles/libc/resolv/res_comp.c,v
retrieving revision 1.15
diff -u -r1.15 res_comp.c
--- res_comp.c	1998/05/29 09:50:03	1.15
+++ res_comp.c	1999/02/03 02:02:43
@@ -75,10 +75,10 @@
 # include "../conf/portability.h"
 #endif
 
-static int	ns_name_ntop __P((const u_char *, char *, size_t));
+extern int	__ns_name_ntop __P((const u_char *, char *, size_t));
 static int	ns_name_pton __P((const char *, u_char *, size_t));
-static int	ns_name_unpack __P((const u_char *, const u_char *,
-				    const u_char *, u_char *, size_t));
+extern int	__ns_name_unpack __P((const u_char *, const u_char *,
+				      const u_char *, u_char *, size_t));
 static int	ns_name_pack __P((const u_char *, u_char *, int,
 				  const u_char **, const u_char **));
 static int	ns_name_uncompress __P((const u_char *, const u_char *,
@@ -370,8 +370,8 @@
  *	The root is returned as "."
  *	All other domains are returned in non absolute form
  */
-static int
-ns_name_ntop(src, dst, dstsiz)
+int
+__ns_name_ntop(src, dst, dstsiz)
 	const u_char *src;
 	char *dst;
 	size_t dstsiz;
@@ -565,8 +565,8 @@
  * return:
  *	-1 if it fails, or consumed octets if it succeeds.
  */
-static int
-ns_name_unpack(msg, eom, src, dst, dstsiz)
+int
+__ns_name_unpack(msg, eom, src, dst, dstsiz)
 	const u_char *msg;
 	const u_char *eom;
 	const u_char *src;
@@ -767,9 +767,9 @@
 	u_char tmp[NS_MAXCDNAME];
 	int n;
 
-	if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
+	if ((n = __ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
 		return (-1);
-	if (ns_name_ntop(tmp, dst, dstsiz) == -1)
+	if (__ns_name_ntop(tmp, dst, dstsiz) == -1)
 		return (-1);
 	return (n);
 }
Index: nss_dns/dns-host.c
===================================================================
RCS file: /glibc/cvsfiles/libc/resolv/nss_dns/dns-host.c,v
retrieving revision 1.13
diff -u -r1.13 dns-host.c
--- dns-host.c	1998/10/18 14:51:05	1.13
+++ dns-host.c	1999/02/03 02:02:47
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Extended from original form by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -116,7 +116,13 @@
   u_char buf[MAXPACKET];
 } querybuf;
 
+/* These functions are defined in res_comp.c.  */
+#define NS_MAXCDNAME	255	/* maximum compressed domain name */
+extern int __ns_name_ntop __P ((const u_char *, char *, size_t));
+extern int __ns_name_unpack __P ((const u_char *, const u_char *,
+				  const u_char *, u_char *, size_t));
 
+
 static enum nss_status getanswer_r (const querybuf *answer, int anslen,
 				    const char *qname, int qtype,
 				    struct hostent *result, char *buffer,
@@ -315,6 +321,7 @@
   char tbuf[MAXDNAME];
   const char *tname;
   int (*name_ok) __P ((const char *));
+  u_char packtmp[NS_MAXCDNAME];
 
   tname = qname;
   result->h_name = NULL;
@@ -346,7 +353,25 @@
       return NSS_STATUS_UNAVAIL;
     }
 
+#if 0
   n = dn_expand (answer->buf, end_of_message, cp, bp, linebuflen);
+#else
+  n = __ns_name_unpack (answer->buf, end_of_message, cp,
+			packtmp, sizeof packtmp);
+  if (n != -1)
+    {
+      n = __ns_name_ntop (packtmp, bp, linebuflen);
+      if (n < 0 && errno == EMSGSIZE)
+	{
+	  *errnop = ERANGE;
+	  *h_errnop = NETDB_INTERNAL;
+	  return NSS_STATUS_TRYAGAIN;
+	}
+    }
+
+  if (n > 0 && bp[0] == '.')
+    bp[0] = '\0';
+#endif
   if (n < 0 || (*name_ok) (bp) == 0)
     {
       if (errno == EMSGSIZE)
@@ -606,7 +631,13 @@
       if (result->h_name == NULL)
 	{
 	  n = strlen (qname) + 1;	/* For the \0.  */
-	  if (n > linebuflen || n >= MAXHOSTNAMELEN)
+	  if (n > linebuflen)
+	    {
+	      *errnop = ERANGE;
+	      *h_errnop = NETDB_INTERNAL;
+	      return NSS_STATUS_TRYAGAIN;
+	    }
+	  if (n >= MAXHOSTNAMELEN)
 	    goto no_recovery;
 	  result->h_name = strcpy (bp, qname);	/* Cannot overflow.  */
 	  bp += n;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]