summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-31 19:53:59 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-31 19:53:59 +0200
commit7b9f7afcc04e80b77a2567b0750aa2cd03c1a1cd (patch)
treec1258c8cef335152021087e5aabf9c6208c20b0b /src
parent07bed172edc819cf85b72d5c67613511cbde5453 (diff)
resolved: accept UTF-8 hostnames from bus clients
Diffstat (limited to 'src')
-rw-r--r--src/resolve/resolved-bus.c7
-rw-r--r--src/resolve/resolved-dns-domain.c8
2 files changed, 11 insertions, 4 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index bfb060d86b..6bd2b53b0e 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -275,7 +275,8 @@ static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, voi
if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
- if (!hostname_is_valid(hostname))
+ r = dns_name_normalize(hostname, NULL);
+ if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", hostname);
question = dns_question_new(family == AF_UNSPEC ? 2 : 1);
@@ -566,6 +567,10 @@ static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void
if (r < 0)
return r;
+ r = dns_name_normalize(name, NULL);
+ if (r < 0)
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid name '%s'", name);
+
question = dns_question_new(1);
if (!question)
return -ENOMEM;
diff --git a/src/resolve/resolved-dns-domain.c b/src/resolve/resolved-dns-domain.c
index c2a435944c..1bb011d9e7 100644
--- a/src/resolve/resolved-dns-domain.c
+++ b/src/resolve/resolved-dns-domain.c
@@ -172,7 +172,6 @@ int dns_name_normalize(const char *s, char **_ret) {
int r;
assert(s);
- assert(_ret);
for (;;) {
_cleanup_free_ char *t = NULL;
@@ -210,8 +209,11 @@ int dns_name_normalize(const char *s, char **_ret) {
return -ENOMEM;
ret[n] = 0;
- *_ret = ret;
- ret = NULL;
+
+ if (_ret) {
+ *_ret = ret;
+ ret = NULL;
+ }
return 0;
}