about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/avahi/CVE-2023-38471-2.patch
blob: be0faddbfef5d6e82f4dddb9752c48d005f33722 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);