6687e87ad2
Resolves: #2186688
57 lines
2.0 KiB
Diff
57 lines
2.0 KiB
Diff
From 509b0d14fa46b7015e0bacf2a8105f1d14d7b5e5 Mon Sep 17 00:00:00 2001
|
|
From: Petr Mensik <pemensik@redhat.com>
|
|
Date: Wed, 23 Aug 2023 18:51:46 +0200
|
|
Subject: [PATCH] Emit error if requested service is not found
|
|
|
|
It currently just crashes instead of replying with error. Check return
|
|
value and emit error instead of passing NULL pointer to reply.
|
|
|
|
Fixes #375
|
|
---
|
|
avahi-daemon/dbus-protocol.c | 20 ++++++++++++++------
|
|
1 file changed, 14 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
|
|
index eb8a662..a9b62fe 100644
|
|
--- a/avahi-daemon/dbus-protocol.c
|
|
+++ b/avahi-daemon/dbus-protocol.c
|
|
@@ -391,10 +391,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
|
|
}
|
|
|
|
t = avahi_alternative_host_name(n);
|
|
- avahi_dbus_respond_string(c, m, t);
|
|
- avahi_free(t);
|
|
+ if (t) {
|
|
+ avahi_dbus_respond_string(c, m, t);
|
|
+ avahi_free(t);
|
|
|
|
- return DBUS_HANDLER_RESULT_HANDLED;
|
|
+ return DBUS_HANDLER_RESULT_HANDLED;
|
|
+ } else {
|
|
+ return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_FOUND, "Hostname not found");
|
|
+ }
|
|
|
|
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetAlternativeServiceName")) {
|
|
char *n, *t;
|
|
@@ -405,10 +409,14 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
|
|
}
|
|
|
|
t = avahi_alternative_service_name(n);
|
|
- avahi_dbus_respond_string(c, m, t);
|
|
- avahi_free(t);
|
|
+ if (t) {
|
|
+ avahi_dbus_respond_string(c, m, t);
|
|
+ avahi_free(t);
|
|
|
|
- return DBUS_HANDLER_RESULT_HANDLED;
|
|
+ return DBUS_HANDLER_RESULT_HANDLED;
|
|
+ } else {
|
|
+ return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_FOUND, "Service not found");
|
|
+ }
|
|
|
|
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "EntryGroupNew")) {
|
|
Client *client;
|
|
--
|
|
2.41.0
|
|
|