about summary refs log tree commit diff
path: root/resolv/res_query.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-07-19 07:55:27 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-07-19 07:56:21 +0200
commitbe5773e1668ab62e980b58c68c3ffd0fd65e31af (patch)
tree5f96d76963ac508f60bb24742c20424fdbdfe0c2 /resolv/res_query.c
parent7131727c6ba451e1c5bf075194c7adc9292906c4 (diff)
downloadglibc-be5773e1668ab62e980b58c68c3ffd0fd65e31af.tar.gz
glibc-be5773e1668ab62e980b58c68c3ffd0fd65e31af.tar.xz
glibc-be5773e1668ab62e980b58c68c3ffd0fd65e31af.zip
resolv: Move __res_context_hostalias into its own file and into libc
And reformat it to GNU style.  Remove the unecessary setbuf call.
Use __fgets_unlocked for PLT avoidance; no locking is required here.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'resolv/res_query.c')
-rw-r--r--resolv/res_query.c40
1 files changed, 0 insertions, 40 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 5b51af8451..45c591ae27 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -635,46 +635,6 @@ res_querydomain (const char *name, const char *domain, int class, int type,
     (__resolv_context_get (), name, domain, class, type, answer, anslen);
 }
 
-const char *
-__res_context_hostalias (struct resolv_context *ctx,
-			 const char *name, char *dst, size_t siz)
-{
-	char *file, *cp1, *cp2;
-	char buf[BUFSIZ];
-	FILE *fp;
-
-	if (ctx->resp->options & RES_NOALIASES)
-		return (NULL);
-	file = getenv("HOSTALIASES");
-	if (file == NULL || (fp = fopen(file, "rce")) == NULL)
-		return (NULL);
-	setbuf(fp, NULL);
-	buf[sizeof(buf) - 1] = '\0';
-	while (fgets(buf, sizeof(buf), fp)) {
-		for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1)
-			;
-		if (!*cp1)
-			break;
-		*cp1 = '\0';
-		if (__libc_ns_samename(buf, name) == 1) {
-			while (isspace(*++cp1))
-				;
-			if (!*cp1)
-				break;
-			for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2)
-				;
-			*cp2 = '\0';
-			strncpy(dst, cp1, siz - 1);
-			dst[siz - 1] = '\0';
-			fclose(fp);
-			return (dst);
-		}
-	}
-	fclose(fp);
-	return (NULL);
-}
-libresolv_hidden_def (__res_context_hostalias)
-
 /* Common part of res_hostalias and hostalias.  */
 static const char *
 context_hostalias_common (struct resolv_context *ctx,