aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resolv_wrapper.c16
-rw-r--r--tests/test_dns_fake.c26
2 files changed, 10 insertions, 32 deletions
diff --git a/src/resolv_wrapper.c b/src/resolv_wrapper.c
index 455a0af..7a3c9b7 100644
--- a/src/resolv_wrapper.c
+++ b/src/resolv_wrapper.c
@@ -625,8 +625,7 @@ static ssize_t rwrap_fake_uri(struct rwrap_fake_rr *rr,
uint8_t *a = answer;
ssize_t resp_size;
size_t rdata_size;
- unsigned char uri_compressed[MAXDNAME];
- ssize_t compressed_len;
+ size_t uri_len;
if (rr->type != ns_t_uri) {
RWRAP_LOG(RWRAP_LOG_ERROR, "Wrong type!\n");
@@ -634,15 +633,8 @@ static ssize_t rwrap_fake_uri(struct rwrap_fake_rr *rr,
}
RWRAP_LOG(RWRAP_LOG_TRACE, "Adding URI RR");
rdata_size = 3 * sizeof(uint16_t);
-
- /* Prepare the data to write */
- compressed_len = ns_name_compress(rr->rrdata.uri_rec.uri,
- uri_compressed, MAXDNAME,
- NULL, NULL);
- if (compressed_len < 0) {
- return -1;
- }
- rdata_size += compressed_len;
+ uri_len = strlen(rr->rrdata.uri_rec.uri) + 1;
+ rdata_size += uri_len;
resp_size = rwrap_fake_rdata_common(ns_t_uri, rdata_size,
rr->key, anslen, &a);
@@ -652,7 +644,7 @@ static ssize_t rwrap_fake_uri(struct rwrap_fake_rr *rr,
NS_PUT16(rr->rrdata.uri_rec.prio, a);
NS_PUT16(rr->rrdata.uri_rec.weight, a);
- memcpy(a, uri_compressed, compressed_len);
+ memcpy(a, rr->rrdata.uri_rec.uri, uri_len);
return resp_size;
}
diff --git a/tests/test_dns_fake.c b/tests/test_dns_fake.c
index d3e9ebe..348135c 100644
--- a/tests/test_dns_fake.c
+++ b/tests/test_dns_fake.c
@@ -362,7 +362,6 @@ static void test_res_fake_uri_query(void **state)
const uint8_t *rrdata;
int prio;
int weight;
- char uri[MAXDNAME];
(void) state; /* unused */
@@ -378,8 +377,8 @@ static void test_res_fake_uri_query(void **state)
/*
* The query must finish w/o an error, have one answer and the answer
- * must be a parseable RR of type SRV and have the priority, weight,
- * port and hostname as in the fake hosts file
+ * must be a parseable RR of type URI and have the priority, weight, and
+ * URI string as in the hosts file.
*/
assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
assert_int_equal(ns_msg_count(handle, ns_s_an), 1);
@@ -390,15 +389,9 @@ static void test_res_fake_uri_query(void **state)
NS_GET16(prio, rrdata);
NS_GET16(weight, rrdata);
- rv = ns_name_uncompress(ns_msg_base(handle),
- ns_msg_end(handle),
- rrdata,
- uri, MAXDNAME);
- assert_int_not_equal(rv, -1);
-
assert_int_equal(prio, 2);
assert_int_equal(weight, 5);
- assert_string_equal(uri, "https://vpn.cwrap.org/VPN");
+ assert_string_equal(rrdata, "https://vpn.cwrap.org/VPN");
}
/*
@@ -417,7 +410,6 @@ static void test_res_fake_uri_query_minimal(void **state)
const uint8_t *rrdata;
int prio;
int weight;
- char uri[MAXDNAME];
(void) state; /* unused */
@@ -433,8 +425,8 @@ static void test_res_fake_uri_query_minimal(void **state)
/*
* The query must finish w/o an error, have one answer and the answer
- * must be a parseable RR of type SRV and have the priority, weight,
- * port and hostname as in the fake hosts file
+ * must be a parseable RR of type URI and have the priority, weight, and
+ * URI string as in the fake hosts file
*/
assert_int_equal(ns_msg_getflag(handle, ns_f_rcode), ns_r_noerror);
assert_int_equal(ns_msg_count(handle, ns_s_an), 1);
@@ -445,15 +437,9 @@ static void test_res_fake_uri_query_minimal(void **state)
NS_GET16(prio, rrdata);
NS_GET16(weight, rrdata);
- rv = ns_name_uncompress(ns_msg_base(handle),
- ns_msg_end(handle),
- rrdata,
- uri, MAXDNAME);
- assert_int_not_equal(rv, -1);
-
assert_int_equal(prio, 1);
assert_int_equal(weight, 100);
- assert_string_equal(uri, "ftp://ftp.cwrap.org/public");
+ assert_string_equal(rrdata, "ftp://ftp.cwrap.org/public");
}
static void test_res_fake_soa_query(void **state)