aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jakub.hrozek@gmail.com>2014-11-04 15:00:17 +0100
committerAndreas Schneider <asn@samba.org>2014-11-27 15:58:34 +0100
commit2388096ae7c0c7924a44cca94290ed7da06498d0 (patch)
tree04d9b08360f49e413f9c10809aaf4df331decaf9
parent049962a9a4e735a46b555842a4cf6b3e721d05cb (diff)
downloadresolv_wrapper-2388096ae7c0c7924a44cca94290ed7da06498d0.tar.gz
resolv_wrapper-2388096ae7c0c7924a44cca94290ed7da06498d0.tar.xz
resolv_wrapper-2388096ae7c0c7924a44cca94290ed7da06498d0.zip
rwrap: Compare dns names case insensitive.
Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
-rw-r--r--src/resolv_wrapper.c2
-rw-r--r--tests/test_dns_fake.c36
2 files changed, 37 insertions, 1 deletions
diff --git a/src/resolv_wrapper.c b/src/resolv_wrapper.c
index 35f426d..07ec85c 100644
--- a/src/resolv_wrapper.c
+++ b/src/resolv_wrapper.c
@@ -538,7 +538,7 @@ static int rwrap_fake_empty_query(const char *key,
#define TYPE_MATCH(type, ns_type, rec_type, str_type, key, query) \
((type) == (ns_type) && \
(strncmp((rec_type), (str_type), sizeof(str_type)) == 0) && \
- (strcmp(key, query)) == 0)
+ (strcasecmp(key, query)) == 0)
/* Reads in a file in the following format:
diff --git a/tests/test_dns_fake.c b/tests/test_dns_fake.c
index 591b3e1..b890060 100644
--- a/tests/test_dns_fake.c
+++ b/tests/test_dns_fake.c
@@ -83,6 +83,41 @@ static void test_res_fake_a_query(void **state)
assert_string_equal(addr, "127.0.0.21");
}
+static void test_res_fake_a_query_case_insensitive(void **state)
+{
+ int rv;
+ struct __res_state dnsstate;
+ unsigned char answer[ANSIZE];
+ char addr[INET_ADDRSTRLEN];
+ ns_msg handle;
+ ns_rr rr; /* expanded resource record */
+
+ (void) state; /* unused */
+
+ memset(&dnsstate, 0, sizeof(struct __res_state));
+ rv = res_ninit(&dnsstate);
+ assert_int_equal(rv, 0);
+
+ rv = res_nquery(&dnsstate, "CWRAP.ORG", ns_c_in, ns_t_a,
+ answer, sizeof(answer));
+ assert_int_not_equal(rv, -1);
+
+ ns_initparse(answer, sizeof(answer), &handle);
+ /* The query must finish w/o an error, have one answer and the answer
+ * must be a parseable RR of type A and have the address that our
+ * fake hosts file contains. Case does not matter.
+ */
+ assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
+ assert_int_equal(ns_msg_count(handle, ns_s_an), 1);
+ assert_int_equal(ns_parserr(&handle, ns_s_an, 0, &rr), 0);
+ assert_int_equal(ns_rr_type(rr), ns_t_a);
+ assert_non_null(inet_ntop(AF_INET, ns_rr_rdata(rr),
+ addr, sizeof(addr)));
+ assert_string_equal(addr, "127.0.0.21");
+
+ res_nclose(&dnsstate);
+}
+
static void test_res_fake_a_query_notfound(void **state)
{
int rv;
@@ -391,6 +426,7 @@ int main(void)
const UnitTest tests[] = {
unit_test(test_res_fake_a_query),
+ unit_test(test_res_fake_a_query_case_insensitive),
unit_test(test_res_fake_a_query_notfound),
unit_test(test_res_fake_aaaa_query),
unit_test(test_res_fake_aaaa_query_notfound),