summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-packet.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-26 23:58:45 +0100
committerTom Gundersen <teg@jklm.no>2015-11-26 23:58:45 +0100
commitc283267467db7a7fde9d15042b907884118e8fea (patch)
tree96cd17736b87a93f5d563f30c6008c6914a24981 /src/resolve/resolved-dns-packet.c
parentf7b5b034e8758079ddc7a915394704fc2a350c37 (diff)
parent422baca0f230913158078fddf884e06c8c64a316 (diff)
Merge pull request #2031 from poettering/resolved-search-domains
resolved. Fully implement search domains for single-label names
Diffstat (limited to 'src/resolve/resolved-dns-packet.c')
-rw-r--r--src/resolve/resolved-dns-packet.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 4b6b6afae8..40b662246f 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -1145,7 +1145,6 @@ int dns_packet_read_name(
/* End of name */
break;
else if (c <= 63) {
- _cleanup_free_ char *t = NULL;
const char *label;
/* Literal label */
@@ -1153,21 +1152,20 @@ int dns_packet_read_name(
if (r < 0)
goto fail;
- r = dns_label_escape(label, c, &t);
- if (r < 0)
- goto fail;
-
- if (!GREEDY_REALLOC(ret, allocated, n + !first + strlen(t) + 1)) {
+ if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX)) {
r = -ENOMEM;
goto fail;
}
- if (!first)
- ret[n++] = '.';
- else
+ if (first)
first = false;
+ else
+ ret[n++] = '.';
+
+ r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
+ if (r < 0)
+ goto fail;
- memcpy(ret + n, t, r);
n += r;
continue;
} else if (allow_compression && (c & 0xc0) == 0xc0) {