resolve: refuse to resolve empty hostname

Previously, varlink or dbus methods return
io.systemd.Resolve.NoNameServers or BUS_ERROR_NO_NAME_SERVERS if an
empty hostname is provided, and thus nss-resolve returns NSS_STATUS_TRYAGAIN.

That causes getaddrinfo() returns 'Temporary failure in name resolution'
instead of 'Name or service not known'.

This makes calling varlink or dbus method with an empty hostname result
-EINVAL, and hence nss-resolve returns NSS_STATUS_NOTFOUND.

Fixes RHBZ#2039854 (https://bugzilla.redhat.com/show_bug.cgi?id=2039854).
This commit is contained in:
Yu Watanabe
2022-01-21 09:45:29 +09:00
parent 9969c901d3
commit 6e8ecb8974
3 changed files with 13 additions and 0 deletions
+4
View File
@@ -60,6 +60,10 @@ static inline int dns_name_is_valid_ldh(const char *s) {
return 1;
}
static inline bool dns_name_is_empty(const char *s) {
return isempty(s) || streq(s, ".");
}
void dns_name_hash_func(const char *s, struct siphash *state);
int dns_name_compare_func(const char *a, const char *b);
extern const struct hash_ops dns_name_hash_ops;