1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-16 10:50:18 +03:00

resolved: accept UTF-8 hostnames from bus clients

This commit is contained in:
Lennart Poettering 2014-07-31 19:53:59 +02:00
parent 07bed172ed
commit 7b9f7afcc0
2 changed files with 11 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}