| From: =?utf-8?b?UGV0ciBNZW7FocOtaw==?= <pemensik@redhat.com> |
| Date: Thu, 17 Nov 2022 01:51:53 +0100 |
| Subject: 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 |
| |
| (cherry picked from commit a2696da2f2c50ac43b6c4903f72290d5c3fa9f6f) |
| --- |
| avahi-daemon/dbus-protocol.c | 20 ++++++++++++++------ |
| 1 file changed, 14 insertions(+), 6 deletions(-) |
| |
| --- a/avahi-daemon/dbus-protocol.c |
| +++ b/avahi-daemon/dbus-protocol.c |
| @@ -375,10 +375,14 @@ static DBusHandlerResult dbus_get_altern |
| } |
| |
| t = avahi_alternative_host_name(n); |
| - avahi_dbus_respond_string(c, m, t); |
| - avahi_free(t); |
| - |
| - return DBUS_HANDLER_RESULT_HANDLED; |
| + if (t) { |
| + avahi_dbus_respond_string(c, m, t); |
| + avahi_free(t); |
| + |
| + return DBUS_HANDLER_RESULT_HANDLED; |
| + } else { |
| + return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_FOUND, "Hostname not found"); |
| + } |
| } |
| |
| static DBusHandlerResult dbus_get_alternative_service_name(DBusConnection *c, DBusMessage *m, DBusError *error) { |
| @@ -389,10 +393,14 @@ static DBusHandlerResult dbus_get_altern |
| } |
| |
| t = avahi_alternative_service_name(n); |
| - avahi_dbus_respond_string(c, m, t); |
| - avahi_free(t); |
| - |
| - return DBUS_HANDLER_RESULT_HANDLED; |
| + if (t) { |
| + avahi_dbus_respond_string(c, m, t); |
| + avahi_free(t); |
| + |
| + return DBUS_HANDLER_RESULT_HANDLED; |
| + } else { |
| + return avahi_dbus_respond_error(c, m, AVAHI_ERR_NOT_FOUND, "Service not found"); |
| + } |
| } |
| |
| static DBusHandlerResult dbus_create_new_entry_group(DBusConnection *c, DBusMessage *m, DBusError *error) { |