aboutsummaryrefslogtreecommitdiffstats
path: root/main/libc0.9.32/0002-resolv-res_query-for-CNAMEs.patch
blob: 466c2fafe799640fb826ee31aabd5cf5ddd3cf16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From e7d64120a2cb382c1167977b0aefa388d5ab62e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Fri, 23 Dec 2011 14:15:16 +0100
Subject: [PATCH 2/8] resolv: res_query for CNAMEs

From: http://lists.busybox.net/pipermail/uclibc/2009-June/042583.html

I had postfix failing for domains with MX->CNAME->A chain. In glibc it works.
I tracked it to be a problem in uclibc res_query. It returns bogus data
for CNAME entries, apparently intentionally, which is wrong.

glibc return CNAME entries even for CNAME queries and most applications rely
on this. So we should do the same in uclibc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 libc/inet/resolv.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index a730584..632bfaf 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -3740,11 +3740,9 @@ int res_query(const char *dname, int class, int type,
 
 	free(a.dotted);
 
-	if (a.atype == type) { /* CNAME */
-		if (i > anslen)
-			i = anslen;
-		memcpy(answer, packet, i);
-	}
+	i = MIN(anslen, i);
+	memcpy(answer, packet, i);
+
 	free(packet);
 	return i;
 }
-- 
1.7.8.4