From 7cb7d8b15bb2136d29f690bbfef9634abf1c21e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 25 Jun 2021 19:23:38 +0200 Subject: [PATCH] pulse-server: module-zeroconf-publish: handle `uname()` failure gracefully Only add the "uname=..." entry to the Avahi string list if `uname()` succeeds. --- .../modules/module-zeroconf-publish.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c index bb91aee05..c86f6d596 100644 --- a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c +++ b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c @@ -315,18 +315,20 @@ static AvahiStringList* txt_record_server_data(struct pw_core_info *info, AvahiS { const char *t; struct utsname u; - char sysname[sizeof(u.sysname) + sizeof(u.machine) + sizeof(u.release)]; spa_assert(info); - spa_assert(uname(&u) >= 0); l = avahi_string_list_add_pair(l, "server-version", PACKAGE_NAME" "PACKAGE_VERSION); t = pw_get_user_name(); l = avahi_string_list_add_pair(l, "user-name", t); - snprintf(sysname, sizeof(sysname), "%s %s %s", u.sysname, u.machine, u.release); - l = avahi_string_list_add_pair(l, "uname", sysname); + if (uname(&u) >= 0) { + char sysname[sizeof(u.sysname) + sizeof(u.machine) + sizeof(u.release)]; + + snprintf(sysname, sizeof(sysname), "%s %s %s", u.sysname, u.machine, u.release); + l = avahi_string_list_add_pair(l, "uname", sysname); + } t = pw_get_host_name(); l = avahi_string_list_add_pair(l, "fqdn", t);