summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/ndisc-router.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-02-02 02:23:56 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-02-07 21:39:21 +0100
commit6244184e3ff2f7659406c2d08a9a4d75e08bccb2 (patch)
treede1a17e4f586402a93a998d1352b11687d0d5f05 /src/libsystemd-network/ndisc-router.c
parentMerge pull request #31176 from yuwata/network-required-for-online (diff)
downloadsystemd-6244184e3ff2f7659406c2d08a9a4d75e08bccb2.tar.xz
systemd-6244184e3ff2f7659406c2d08a9a4d75e08bccb2.zip
sd-ndisc: make sd_ndisc_router_dnssl_get_domains() return -EBADMSG when received invalid domain name
Fixes #31168.
Diffstat (limited to '')
-rw-r--r--src/libsystemd-network/ndisc-router.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libsystemd-network/ndisc-router.c b/src/libsystemd-network/ndisc-router.c
index 89681d0075..e50a0b966b 100644
--- a/src/libsystemd-network/ndisc-router.c
+++ b/src/libsystemd-network/ndisc-router.c
@@ -9,6 +9,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
+#include "escape.h"
#include "hostname-util.h"
#include "memory-util.h"
#include "missing_network.h"
@@ -716,8 +717,12 @@ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret) {
e[n] = 0;
r = dns_name_normalize(e, 0, &normalized);
- if (r < 0)
- return r;
+ if (r < 0) {
+ _cleanup_free_ char *escaped = cescape(e);
+ log_debug_errno(r, "Failed to normalize advertised domain name \"%s\": %m", strna(escaped));
+ /* Here, do not propagate error code from dns_name_normalize() except for ENOMEM. */
+ return r == -ENOMEM ? -ENOMEM : -EBADMSG;
+ }
/* Ignore the root domain name or "localhost" and friends */
if (!is_localhost(normalized) &&
@@ -753,8 +758,12 @@ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret) {
e[n++] = '.';
r = dns_label_escape((char*) p+1, *p, e + n, DNS_LABEL_ESCAPED_MAX);
- if (r < 0)
- return r;
+ if (r < 0) {
+ _cleanup_free_ char *escaped = cescape_length((const char*) p+1, *p);
+ log_debug_errno(r, "Failed to escape advertised domain name \"%s\": %m", strna(escaped));
+ /* Here, do not propagate error code from dns_label_escape() except for ENOMEM. */
+ return r == -ENOMEM ? -ENOMEM : -EBADMSG;
+ }
n += r;