504525a148
GitOrigin-RevId: bd645e8668ec6612439a9ee7e71f7eac4099d4f6
47 lines
1.8 KiB
Diff
47 lines
1.8 KiB
Diff
From 04ac71fd56a16365360f14bd4691219913e22f21 Mon Sep 17 00:00:00 2001
|
|
From: Evgeny Vereshchagin <evvers@ya.ru>
|
|
Date: Tue, 24 Oct 2023 21:57:32 +0000
|
|
Subject: [PATCH 1/2] smoke-test: call SetHostName with unusual names
|
|
|
|
It's prompted by https://github.com/lathiat/avahi/issues/453
|
|
---
|
|
avahi-core/server.c | 9 ++++++---
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/avahi-core/server.c b/avahi-core/server.c
|
|
index f6a21bb7..84df6b5d 100644
|
|
--- a/avahi-core/server.c
|
|
+++ b/avahi-core/server.c
|
|
@@ -1309,10 +1309,13 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
|
|
else
|
|
hn = avahi_normalize_name_strdup(host_name);
|
|
|
|
+ if (!hn)
|
|
+ return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
|
|
+
|
|
h = hn;
|
|
if (!avahi_unescape_label((const char **)&hn, label, sizeof(label))) {
|
|
avahi_free(h);
|
|
- return AVAHI_ERR_INVALID_HOST_NAME;
|
|
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
|
|
}
|
|
|
|
avahi_free(h);
|
|
@@ -1320,7 +1323,7 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
|
|
h = label_escaped;
|
|
len = sizeof(label_escaped);
|
|
if (!avahi_escape_label(label, strlen(label), &h, &len))
|
|
- return AVAHI_ERR_INVALID_HOST_NAME;
|
|
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
|
|
|
|
if (avahi_domain_equal(s->host_name, label_escaped) && s->state != AVAHI_SERVER_COLLISION)
|
|
return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
|
|
@@ -1330,7 +1333,7 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
|
|
avahi_free(s->host_name);
|
|
s->host_name = avahi_strdup(label_escaped);
|
|
if (!s->host_name)
|
|
- return AVAHI_ERR_NO_MEMORY;
|
|
+ return avahi_server_set_errno(s, AVAHI_ERR_NO_MEMORY);
|
|
|
|
update_fqdn(s);
|
|
|