]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dns-question.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / resolve / resolved-dns-question.c
index c8b502d1cd7fc22cdf121ab42a3bfb464c7140e5..4dc3de40526472533d7e4b6a99ae8c42c6c5fd10 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -309,8 +310,14 @@ int dns_question_new_address(DnsQuestion **ret, int family, const char *name, bo
                 r = dns_name_apply_idna(name, &buf);
                 if (r < 0)
                         return r;
-
-                name = buf;
+                if (r > 0 && !streq(name, buf))
+                        name = buf;
+                else
+                        /* We did not manage to create convert the idna name, or it's
+                         * the same as the original name. We assume the caller already
+                         * created an uncoverted question, so let's not repeat work
+                         * unnecessarily. */
+                        return -EALREADY;
         }
 
         q = dns_question_new(family == AF_UNSPEC ? 2 : 1);
@@ -422,8 +429,8 @@ int dns_question_new_service(
                         r = dns_name_apply_idna(domain, &buf);
                         if (r < 0)
                                 return r;
-
-                        domain = buf;
+                        if (r > 0)
+                                domain = buf;
                 }
 
                 r = dns_service_join(service, type, domain, &joined);