summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
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/libsystemd-network
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/libsystemd-network')
-rw-r--r--src/libsystemd-network/dhcp6-option.c18
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c4
2 files changed, 10 insertions, 12 deletions
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index 62023a9e49..850212aea1 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -360,7 +360,6 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
/* End of name */
break;
else if (c <= 63) {
- _cleanup_free_ char *t = NULL;
const char *label;
/* Literal label */
@@ -369,21 +368,20 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
if (pos > optlen)
return -EMSGSIZE;
- r = dns_label_escape(label, c, &t);
- if (r < 0)
- goto fail;
-
- if (!GREEDY_REALLOC0(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 {
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 5ec0e661f7..f689c59a1a 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -604,7 +604,7 @@ static int client_send_discover(sd_dhcp_client *client) {
their messages MUST NOT also send the Host Name option". Just send
one of the two depending on the hostname type.
*/
- if (dns_name_single_label(client->hostname)) {
+ if (dns_name_is_single_label(client->hostname)) {
/* it is unclear from RFC 2131 if client should send hostname in
DHCPDISCOVER but dhclient does and so we do as well
*/
@@ -719,7 +719,7 @@ static int client_send_request(sd_dhcp_client *client) {
}
if (client->hostname) {
- if (dns_name_single_label(client->hostname))
+ if (dns_name_is_single_label(client->hostname))
r = dhcp_option_append(&request->dhcp, optlen, &optoffset, 0,
DHCP_OPTION_HOST_NAME,
strlen(client->hostname), client->hostname);