00db10
This backports the hesiod subdirectory up to and including these
00db10
upstream commits:
00db10
00db10
commit bfff8b1becd7d01c074177df7196ab327cd8c844
00db10
Author: Joseph Myers <joseph@codesourcery.com>
00db10
Date:   Sun Jan 1 00:14:16 2017 +0000
00db10
00db10
    Update copyright dates with scripts/update-copyrights.
00db10
00db10
commit 8a03ccbb77f52ec4b55062eeedddb8daec1a33e4
00db10
Author: Florian Weimer <fweimer@redhat.com>
00db10
Date:   Mon May 2 16:04:32 2016 +0200
00db10
00db10
    hesiod: Avoid heap overflow in get_txt_records [BZ #20031]
00db10
00db10
It is required to eliminate a dependency on resolver internals.
00db10
00db10
diff --git a/hesiod/Makefile b/hesiod/Makefile
00db10
index 5aeb86eaf8971535..3c967441e17240b4 100644
00db10
--- a/hesiod/Makefile
00db10
+++ b/hesiod/Makefile
00db10
@@ -1,4 +1,4 @@
00db10
-# Copyright (C) 1997, 1998, 2000, 2001, 2012 Free Software Foundation, Inc.
00db10
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
 # This file is part of the GNU C Library.
00db10
 
00db10
 # The GNU C Library is free software; you can redistribute it and/or
00db10
@@ -20,13 +20,15 @@
00db10
 #
00db10
 subdir	:= hesiod
00db10
 
00db10
+include ../Makeconfig
00db10
+
00db10
 extra-libs := libnss_hesiod
00db10
 extra-libs-others = $(extra-libs)
00db10
 
00db10
 subdir-dirs = nss_hesiod
00db10
 vpath %.c nss_hesiod
00db10
 
00db10
-libnss_hesiod-routines	:= hesiod hesiod-grp hesiod-init hesiod-proto \
00db10
+libnss_hesiod-routines	:= hesiod hesiod-grp hesiod-proto \
00db10
 			   hesiod-pwd hesiod-service
00db10
 # Build only shared library
00db10
 libnss_hesiod-inhibit-o	= $(filter-out .os,$(object-suffixes))
00db10
diff --git a/hesiod/hesiod.c b/hesiod/hesiod.c
00db10
index 657dabebc144db7d..9b54d1cb6b18f0e5 100644
00db10
--- a/hesiod/hesiod.c
00db10
+++ b/hesiod/hesiod.c
00db10
@@ -1,6 +1,19 @@
00db10
-#if defined(LIBC_SCCS) && !defined(lint)
00db10
-static const char rcsid[] = "$BINDId: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie Exp $";
00db10
-#endif
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
 
00db10
 /*
00db10
  * Copyright (c) 1996,1999 by Internet Software Consortium.
00db10
@@ -46,24 +59,14 @@ static const char rcsid[] = "$BINDId: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie
00db10
 
00db10
 #include "hesiod.h"
00db10
 #include "hesiod_p.h"
00db10
-#undef DEF_RHS
00db10
 
00db10
 #define _PATH_HESIOD_CONF "/etc/hesiod.conf"
00db10
 
00db10
 /* Forward */
00db10
 
00db10
-int		hesiod_init(void **context);
00db10
-void		hesiod_end(void *context);
00db10
-char *		hesiod_to_bind(void *context, const char *name,
00db10
-			       const char *type);
00db10
-char **		hesiod_resolve(void *context, const char *name,
00db10
-			       const char *type);
00db10
-void		hesiod_free_list(void *context, char **list);
00db10
-
00db10
 static int	parse_config_file(struct hesiod_p *ctx, const char *filename);
00db10
 static char **	get_txt_records(struct hesiod_p *ctx, int class,
00db10
 				const char *name);
00db10
-static int	init(struct hesiod_p *ctx);
00db10
 
00db10
 /* Public */
00db10
 
00db10
@@ -82,7 +85,6 @@ hesiod_init(void **context) {
00db10
 
00db10
 	ctx->LHS = NULL;
00db10
 	ctx->RHS = NULL;
00db10
-	ctx->res = NULL;
00db10
 	/* Set default query classes. */
00db10
 	ctx->classes[0] = C_IN;
00db10
 	ctx->classes[1] = C_HS;
00db10
@@ -91,19 +93,7 @@ hesiod_init(void **context) {
00db10
 	if (!configname)
00db10
 	  configname = _PATH_HESIOD_CONF;
00db10
 	if (parse_config_file(ctx, configname) < 0) {
00db10
-#ifdef DEF_RHS
00db10
-		/*
00db10
-		 * Use compiled in defaults.
00db10
-		 */
00db10
-		ctx->LHS = malloc(strlen(DEF_LHS)+1);
00db10
-		ctx->RHS = malloc(strlen(DEF_RHS)+1);
00db10
-		if (ctx->LHS == 0 || ctx->RHS == 0)
00db10
-			goto cleanup;
00db10
-		strcpy(ctx->LHS, DEF_LHS);
00db10
-		strcpy(ctx->RHS, DEF_RHS);
00db10
-#else
00db10
 		goto cleanup;
00db10
-#endif
00db10
 	}
00db10
 	/*
00db10
 	 * The default RHS can be overridden by an environment
00db10
@@ -131,11 +121,6 @@ hesiod_init(void **context) {
00db10
 		goto cleanup;
00db10
 	}
00db10
 
00db10
-#if 0
00db10
-	if (res_ninit(ctx->res) < 0)
00db10
-		goto cleanup;
00db10
-#endif
00db10
-
00db10
 	*context = ctx;
00db10
 	return (0);
00db10
 
00db10
@@ -152,12 +137,8 @@ hesiod_end(void *context) {
00db10
 	struct hesiod_p *ctx = (struct hesiod_p *) context;
00db10
 	int save_errno = errno;
00db10
 
00db10
-	if (ctx->res)
00db10
-		res_nclose(ctx->res);
00db10
 	free(ctx->RHS);
00db10
 	free(ctx->LHS);
00db10
-	if (ctx->res && ctx->free_res)
00db10
-		(*ctx->free_res)(ctx->res);
00db10
 	free(ctx);
00db10
 	__set_errno(save_errno);
00db10
 }
00db10
@@ -232,10 +213,6 @@ hesiod_resolve(void *context, const char *name, const char *type) {
00db10
 
00db10
 	if (bindname == NULL)
00db10
 		return (NULL);
00db10
-	if (init(ctx) == -1) {
00db10
-		free(bindname);
00db10
-		return (NULL);
00db10
-	}
00db10
 
00db10
 	retvec = get_txt_records(ctx, ctx->classes[0], bindname);
00db10
 
00db10
@@ -365,13 +342,13 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
00db10
 	/*
00db10
 	 * Construct the query and send it.
00db10
 	 */
00db10
-	n = res_nmkquery(ctx->res, QUERY, name, class, T_TXT, NULL, 0,
00db10
+	n = res_mkquery(QUERY, name, class, T_TXT, NULL, 0,
00db10
 			 NULL, qbuf, MAX_HESRESP);
00db10
 	if (n < 0) {
00db10
 		__set_errno(EMSGSIZE);
00db10
 		return (NULL);
00db10
 	}
00db10
-	n = res_nsend(ctx->res, qbuf, n, abuf, MAX_HESRESP);
00db10
+	n = res_send(qbuf, n, abuf, MAX_HESRESP);
00db10
 	if (n < 0) {
00db10
 		__set_errno(ECONNREFUSED);
00db10
 		return (NULL);
00db10
@@ -421,7 +398,7 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
00db10
 		cp += INT16SZ + INT32SZ;	/* skip the ttl, too */
00db10
 		rr.dlen = ns_get16(cp);
00db10
 		cp += INT16SZ;
00db10
-		if (cp + rr.dlen > eom) {
00db10
+		if (rr.dlen == 0 || cp + rr.dlen > eom) {
00db10
 			__set_errno(EMSGSIZE);
00db10
 			goto cleanup;
00db10
 		}
00db10
@@ -464,44 +441,3 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
00db10
 	free(list);
00db10
 	return (NULL);
00db10
 }
00db10
-
00db10
-struct __res_state *
00db10
-__hesiod_res_get(void *context) {
00db10
-	struct hesiod_p *ctx = context;
00db10
-
00db10
-	if (!ctx->res) {
00db10
-		struct __res_state *res;
00db10
-		res = (struct __res_state *)calloc(1, sizeof *res);
00db10
-		if (res == NULL)
00db10
-			return (NULL);
00db10
-		__hesiod_res_set(ctx, res, free);
00db10
-	}
00db10
-
00db10
-	return (ctx->res);
00db10
-}
00db10
-
00db10
-void
00db10
-__hesiod_res_set(void *context, struct __res_state *res,
00db10
-		 void (*free_res)(void *)) {
00db10
-	struct hesiod_p *ctx = context;
00db10
-
00db10
-	if (ctx->res && ctx->free_res) {
00db10
-		res_nclose(ctx->res);
00db10
-		(*ctx->free_res)(ctx->res);
00db10
-	}
00db10
-
00db10
-	ctx->res = res;
00db10
-	ctx->free_res = free_res;
00db10
-}
00db10
-
00db10
-static int
00db10
-init(struct hesiod_p *ctx) {
00db10
-
00db10
-	if (!ctx->res && !__hesiod_res_get(ctx))
00db10
-		return (-1);
00db10
-
00db10
-	if (__res_maybe_init (ctx->res, 0) == -1)
00db10
-		return (-1);
00db10
-
00db10
-	return (0);
00db10
-}
00db10
diff --git a/hesiod/hesiod.h b/hesiod/hesiod.h
00db10
index 82fce30764e15071..2cb640a7df668cab 100644
00db10
--- a/hesiod/hesiod.h
00db10
+++ b/hesiod/hesiod.h
00db10
@@ -1,3 +1,20 @@
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
 /*
00db10
  * Copyright (c) 1996,1999 by Internet Software Consortium.
00db10
  *
00db10
@@ -19,22 +36,15 @@
00db10
  * This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
00db10
  */
00db10
 
00db10
-/*
00db10
- * $BINDId: hesiod.h,v 1.7 1999/01/08 19:22:45 vixie Exp $
00db10
- */
00db10
-
00db10
 #ifndef _HESIOD_H_INCLUDED
00db10
 #define _HESIOD_H_INCLUDED
00db10
 
00db10
-int		hesiod_init (void **context);
00db10
-void		hesiod_end (void *context);
00db10
+int		hesiod_init (void **context) attribute_hidden;
00db10
+void		hesiod_end (void *context) attribute_hidden;
00db10
 char *		hesiod_to_bind (void *context, const char *name,
00db10
-				const char *type);
00db10
+				const char *type) attribute_hidden;
00db10
 char **		hesiod_resolve (void *context, const char *name,
00db10
-				const char *type);
00db10
-void		hesiod_free_list (void *context, char **list);
00db10
-struct __res_state * __hesiod_res_get (void *context);
00db10
-void		__hesiod_res_set (void *context, struct __res_state *,
00db10
-				  void (*)(void *));
00db10
+				const char *type) attribute_hidden;
00db10
+void		hesiod_free_list (void *context, char **list) attribute_hidden;
00db10
 
00db10
 #endif /*_HESIOD_H_INCLUDED*/
00db10
diff --git a/hesiod/hesiod_p.h b/hesiod/hesiod_p.h
00db10
index 5010d71bc91879c4..7ed70158d9ffc5cc 100644
00db10
--- a/hesiod/hesiod_p.h
00db10
+++ b/hesiod/hesiod_p.h
00db10
@@ -1,3 +1,20 @@
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
 /*
00db10
  * Copyright (c) 1996,1999 by Internet Software Consortium.
00db10
  *
00db10
@@ -20,27 +37,17 @@
00db10
  */
00db10
 
00db10
 /*
00db10
- * $BINDId: hesiod_p.h,v 1.9 1999/01/08 19:24:39 vixie Exp $
00db10
- */
00db10
-
00db10
-/*
00db10
  * hesiod_p.h -- private definitions for the hesiod library
00db10
  */
00db10
 
00db10
 #ifndef _HESIOD_P_H_INCLUDED
00db10
 #define _HESIOD_P_H_INCLUDED
00db10
 
00db10
-#define DEF_RHS		".Athena.MIT.EDU"	/* Defaults if HESIOD_CONF */
00db10
 #define DEF_LHS		".ns"			/*    file is not */
00db10
 						/*    present. */
00db10
 struct hesiod_p {
00db10
 	char *		LHS;		/* normally ".ns" */
00db10
 	char *		RHS;		/* AKA the default hesiod domain */
00db10
-	struct __res_state * res;	/* resolver context */
00db10
-	void		(*free_res)(void *);
00db10
-	void		(*res_set)(struct hesiod_p *, struct __res_state *,
00db10
-				   void (*)(void *));
00db10
-	struct __res_state * (*res_get)(struct hesiod_p *);
00db10
 	int		classes[2];	/* The class search order. */
00db10
 };
00db10
 
00db10
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
00db10
index 5c14554ce9fd647e..a04f5309453047e2 100644
00db10
--- a/hesiod/nss_hesiod/hesiod-grp.c
00db10
+++ b/hesiod/nss_hesiod/hesiod-grp.c
00db10
@@ -1,4 +1,4 @@
00db10
-/* Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
00db10
 
00db10
@@ -26,8 +26,6 @@
00db10
 #include <string.h>
00db10
 #include <sys/param.h>
00db10
 
00db10
-#include "nss_hesiod.h"
00db10
-
00db10
 /* Get the declaration of the parser function.  */
00db10
 #define ENTNAME grent
00db10
 #define STRUCTURE group
00db10
@@ -58,8 +56,7 @@ lookup (const char *name, const char *type, struct group *grp,
00db10
   size_t len;
00db10
   int olderr = errno;
00db10
 
00db10
-  context = _nss_hesiod_init ();
00db10
-  if (context == NULL)
00db10
+  if (hesiod_init (&context) < 0)
00db10
     return NSS_STATUS_UNAVAIL;
00db10
 
00db10
   list = hesiod_resolve (context, name, type);
00db10
@@ -179,8 +176,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
00db10
   gid_t *groups = *groupsp;
00db10
   int save_errno;
00db10
 
00db10
-  context = _nss_hesiod_init ();
00db10
-  if (context == NULL)
00db10
+  if (hesiod_init (&context) < 0)
00db10
     return NSS_STATUS_UNAVAIL;
00db10
 
00db10
   list = hesiod_resolve (context, user, "grplist");
00db10
@@ -191,33 +187,6 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
00db10
       return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
00db10
     }
00db10
 
00db10
-  if (!internal_gid_in_list (groups, group, *start))
00db10
-    {
00db10
-      if (__builtin_expect (*start == *size, 0))
00db10
-	{
00db10
-	  /* Need a bigger buffer.  */
00db10
-	  gid_t *newgroups;
00db10
-	  long int newsize;
00db10
-
00db10
-	  if (limit > 0 && *size == limit)
00db10
-	    /* We reached the maximum.  */
00db10
-	    goto done;
00db10
-
00db10
-	  if (limit <= 0)
00db10
-	    newsize = 2 * *size;
00db10
-	  else
00db10
-	    newsize = MIN (limit, 2 * *size);
00db10
-
00db10
-	  newgroups = realloc (groups, newsize * sizeof (*groups));
00db10
-	  if (newgroups == NULL)
00db10
-	    goto done;
00db10
-	  *groupsp = groups = newgroups;
00db10
-	  *size = newsize;
00db10
-	}
00db10
-
00db10
-      groups[(*start)++] = group;
00db10
-    }
00db10
-
00db10
   save_errno = errno;
00db10
 
00db10
   p = *list;
00db10
@@ -254,7 +223,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
00db10
 	  if (status == NSS_STATUS_SUCCESS
00db10
 	      && !internal_gid_in_list (groups, group, *start))
00db10
 	    {
00db10
-	      if (__builtin_expect (*start == *size, 0))
00db10
+	      if (__glibc_unlikely (*start == *size))
00db10
 		{
00db10
 		  /* Need a bigger buffer.  */
00db10
 		  gid_t *newgroups;
00db10
diff --git a/hesiod/nss_hesiod/hesiod-init.c b/hesiod/nss_hesiod/hesiod-init.c
00db10
deleted file mode 100644
00db10
index 964987d0755425b5..0000000000000000
00db10
--- a/hesiod/nss_hesiod/hesiod-init.c
00db10
+++ /dev/null
00db10
@@ -1,38 +0,0 @@
00db10
-/* Copyright (C) 2000 Free Software Foundation, Inc.
00db10
-   This file is part of the GNU C Library.
00db10
-   Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
00db10
-
00db10
-   The GNU C Library is free software; you can redistribute it and/or
00db10
-   modify it under the terms of the GNU Lesser General Public
00db10
-   License as published by the Free Software Foundation; either
00db10
-   version 2.1 of the License, or (at your option) any later version.
00db10
-
00db10
-   The GNU C Library is distributed in the hope that it will be useful,
00db10
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
-   Lesser General Public License for more details.
00db10
-
00db10
-   You should have received a copy of the GNU Lesser General Public
00db10
-   License along with the GNU C Library; if not, see
00db10
-   <http://www.gnu.org/licenses/>.  */
00db10
-
00db10
-#include <sys/cdefs.h>		/* Needs to come before <hesiod.h>.  */
00db10
-#include <hesiod.h>
00db10
-#include <resolv.h>
00db10
-#include <stddef.h>
00db10
-
00db10
-#include "nss_hesiod.h"
00db10
-
00db10
-void *
00db10
-_nss_hesiod_init (void)
00db10
-{
00db10
-  void *context;
00db10
-
00db10
-  if (hesiod_init (&context) == -1)
00db10
-    return NULL;
00db10
-
00db10
-  /* Use the default (per-thread) resolver state.  */
00db10
-  __hesiod_res_set (context, &_res, NULL);
00db10
-
00db10
-  return context;
00db10
-}
00db10
diff --git a/hesiod/nss_hesiod/hesiod-proto.c b/hesiod/nss_hesiod/hesiod-proto.c
00db10
index 7ea38bc24fbff3ca..6af32aad35edfc0a 100644
00db10
--- a/hesiod/nss_hesiod/hesiod-proto.c
00db10
+++ b/hesiod/nss_hesiod/hesiod-proto.c
00db10
@@ -1,4 +1,4 @@
00db10
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
00db10
 
00db10
@@ -25,8 +25,6 @@
00db10
 #include <stdlib.h>
00db10
 #include <string.h>
00db10
 
00db10
-#include "nss_hesiod.h"
00db10
-
00db10
 /* Declare a parser for Hesiod protocol entries.  Although the format
00db10
    of the entries is identical to those in /etc/protocols, here is no
00db10
    predefined parser for us to use.  */
00db10
@@ -68,8 +66,7 @@ lookup (const char *name, const char *type, struct protoent *proto,
00db10
   int found;
00db10
   int olderr = errno;
00db10
 
00db10
-  context = _nss_hesiod_init ();
00db10
-  if (context == NULL)
00db10
+  if (hesiod_init (&context) < 0)
00db10
     return NSS_STATUS_UNAVAIL;
00db10
 
00db10
   list = hesiod_resolve (context, name, type);
00db10
diff --git a/hesiod/nss_hesiod/hesiod-pwd.c b/hesiod/nss_hesiod/hesiod-pwd.c
00db10
index 929cbce80e238a67..8309af245d3f0268 100644
00db10
--- a/hesiod/nss_hesiod/hesiod-pwd.c
00db10
+++ b/hesiod/nss_hesiod/hesiod-pwd.c
00db10
@@ -1,4 +1,4 @@
00db10
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
00db10
 
00db10
@@ -24,8 +24,6 @@
00db10
 #include <stdlib.h>
00db10
 #include <string.h>
00db10
 
00db10
-#include "nss_hesiod.h"
00db10
-
00db10
 /* Get the declaration of the parser function.  */
00db10
 #define ENTNAME pwent
00db10
 #define STRUCTURE passwd
00db10
@@ -56,8 +54,7 @@ lookup (const char *name, const char *type, struct passwd *pwd,
00db10
   size_t len;
00db10
   int olderr = errno;
00db10
 
00db10
-  context = _nss_hesiod_init ();
00db10
-  if (context == NULL)
00db10
+  if (hesiod_init (&context) < 0)
00db10
     return NSS_STATUS_UNAVAIL;
00db10
 
00db10
   list = hesiod_resolve (context, name, type);
00db10
diff --git a/hesiod/nss_hesiod/hesiod-service.c b/hesiod/nss_hesiod/hesiod-service.c
00db10
index 28bd31a70f31c89c..1942188517d94508 100644
00db10
--- a/hesiod/nss_hesiod/hesiod-service.c
00db10
+++ b/hesiod/nss_hesiod/hesiod-service.c
00db10
@@ -1,4 +1,4 @@
00db10
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
00db10
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
00db10
 
00db10
@@ -25,8 +25,6 @@
00db10
 #include <stdlib.h>
00db10
 #include <string.h>
00db10
 
00db10
-#include "nss_hesiod.h"
00db10
-
00db10
 /* Hesiod uses a format for service entries that differs from the
00db10
    traditional format.  We therefore declare our own parser.  */
00db10
 
00db10
@@ -69,8 +67,7 @@ lookup (const char *name, const char *type, const char *protocol,
00db10
   int found;
00db10
   int olderr = errno;
00db10
 
00db10
-  context = _nss_hesiod_init ();
00db10
-  if (context == NULL)
00db10
+  if (hesiod_init (&context) < 0)
00db10
     return NSS_STATUS_UNAVAIL;
00db10
 
00db10
   list = hesiod_resolve (context, name, type);
00db10
diff --git a/hesiod/nss_hesiod/nss_hesiod.h b/hesiod/nss_hesiod/nss_hesiod.h
00db10
deleted file mode 100644
00db10
index fdf0241860b7e825..0000000000000000
00db10
--- a/hesiod/nss_hesiod/nss_hesiod.h
00db10
+++ /dev/null
00db10
@@ -1,20 +0,0 @@
00db10
-/* Copyright (C) 2000 Free Software Foundation, Inc.
00db10
-   This file is part of the GNU C Library.
00db10
-   Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
00db10
-
00db10
-   The GNU C Library is free software; you can redistribute it and/or
00db10
-   modify it under the terms of the GNU Lesser General Public
00db10
-   License as published by the Free Software Foundation; either
00db10
-   version 2.1 of the License, or (at your option) any later version.
00db10
-
00db10
-   The GNU C Library is distributed in the hope that it will be useful,
00db10
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
-   Lesser General Public License for more details.
00db10
-
00db10
-   You should have received a copy of the GNU Lesser General Public
00db10
-   License along with the GNU C Library; if not, see
00db10
-   <http://www.gnu.org/licenses/>.  */
00db10
-
00db10
-/* Initialize a Hesiod context.  */
00db10
-extern void *_nss_hesiod_init (void);