aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-11-20 23:14:18 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-11-20 23:14:18 +0200
commit47011c42b5bd5fd7e0898c5a7d4623cd5f5edafa (patch)
tree22f933fb2633833a1c5a3373e886484b18767c46
parent59f7cf0f14bd696603588c4f477fe851bbc801fd (diff)
downloadmailfromd-47011c42b5bd5fd7e0898c5a7d4623cd5f5edafa.tar.gz
mailfromd-47011c42b5bd5fd7e0898c5a7d4623cd5f5edafa.tar.bz2
Concatenate segments of a TXT record.
* lib/dns.c (txt_lookup): Concatenate multiple ans->rrs.manyistr.
-rw-r--r--lib/dns.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/dns.c b/lib/dns.c
index ac6c4d8c..3119aece 100644
--- a/lib/dns.c
+++ b/lib/dns.c
@@ -549,8 +549,22 @@ txt_lookup(const char *name, struct dns_reply *reply)
if (status == dns_success) {
int i;
dns_reply_init(reply, dns_reply_str, ans->nrrs);
- for (i = 0; i < ans->nrrs; i++)
- reply->data.str[i] = mu_strdup(ans->rrs.manyistr[i]->str);
+ for (i = 0; i < ans->nrrs; i++) {
+ size_t l = 0;
+ int j;
+ for (j = 0; ans->rrs.manyistr[i][j].i > 0; j++)
+ l += ans->rrs.manyistr[i][j].i;
+ reply->data.str[i] = mu_alloc(l + 1);
+ reply->data.str[i][0] = 0;
+ l = 0;
+ for (j = 0; ans->rrs.manyistr[i][j].i > 0; j++) {
+ memcpy(reply->data.str[i] + l,
+ ans->rrs.manyistr[i][j].str,
+ ans->rrs.manyistr[i][j].i);
+ l += ans->rrs.manyistr[i][j].i;
+ }
+ reply->data.str[i][l] = 0;
+ }
}
free(ans);
return status;

Return to:

Send suggestions and report system problems to the System administrator.