From b15941d4e188eb76f749ab373eb20ff98e6d3655 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 22 Mar 2020 13:54:04 -0500 Subject: [PATCH 1/2] avahi - handle client pointer null --- common/SoapyMDNSEndpointAvahi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/SoapyMDNSEndpointAvahi.cpp b/common/SoapyMDNSEndpointAvahi.cpp index 0a14526..8081bf0 100644 --- a/common/SoapyMDNSEndpointAvahi.cpp +++ b/common/SoapyMDNSEndpointAvahi.cpp @@ -171,6 +171,7 @@ SoapyMDNSEndpoint::~SoapyMDNSEndpoint(void) void SoapyMDNSEndpoint::printInfo(void) { //summary of avahi client connection for server logging + if (_impl->client == nullptr) return; SoapySDR::logf(SOAPY_SDR_INFO, "Avahi version: %s", avahi_client_get_version_string(_impl->client)); SoapySDR::logf(SOAPY_SDR_INFO, "Avahi hostname: %s", avahi_client_get_host_name(_impl->client)); SoapySDR::logf(SOAPY_SDR_INFO, "Avahi domain: %s", avahi_client_get_domain_name(_impl->client)); @@ -179,11 +180,13 @@ void SoapyMDNSEndpoint::printInfo(void) bool SoapyMDNSEndpoint::status(void) { + if (_impl->client == nullptr) return false; return avahi_client_get_state(_impl->client) != AVAHI_CLIENT_FAILURE; } void SoapyMDNSEndpoint::registerService(const std::string &uuid, const std::string &service, const int ipVer) { + if (_impl->client == nullptr) return; auto &client = _impl->client; auto &group = _impl->group; group = avahi_entry_group_new(client, &groupCallback, this); @@ -372,6 +375,8 @@ static void browserCallback( std::map> SoapyMDNSEndpoint::getServerURLs(const int ipVerReq, const long timeoutUs) { + if (_impl->client == nullptr) return {}; + const auto exitTime = std::chrono::high_resolution_clock::now() + std::chrono::microseconds(timeoutUs); std::lock_guard l(_impl->mutex); From 36293aaa59217f07e4140b878d2ac85da9a6839d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 6 Jul 2020 14:27:08 -0500 Subject: [PATCH 2/2] updated changelog --- Changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 2d359ff..7abdebd 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,8 @@ Release 0.5.2 (pending) ========================== +- Handle cases where avahi client is null +- Protect getServerURLs() with mutex - Handle EINTR case for SSDP server select - Fix the scale in CS12 - CF32 conversion - Protect getServerURLs from re-entrant calls