From bcbcaa54a2013be96c760e93d30da7f16bf347e4 Mon Sep 17 00:00:00 2001 From: Vibhav Pant Date: Mon, 11 Sep 2023 17:39:03 +0530 Subject: [PATCH] Avoid raising an exception in case of an invalid text attribute --- internal/platform/implementation/linux/avahi.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/platform/implementation/linux/avahi.cc b/internal/platform/implementation/linux/avahi.cc index b9c5b068..1092a73b 100644 --- a/internal/platform/implementation/linux/avahi.cc +++ b/internal/platform/implementation/linux/avahi.cc @@ -52,6 +52,7 @@ void ServiceBrowser::onItemNew(const int32_t &interface, size_t pos = attr_str.find('='); if (pos == 0 || pos == std::string::npos || pos == attr_str.size() - 1) { NEARBY_LOGS(WARNING) << " found invalid text attribute: " << attr_str; + continue; } info.SetTxtRecord(attr_str.substr(0, pos), attr_str.substr(pos + 1)); @@ -94,6 +95,7 @@ void ServiceBrowser::onItemRemove( size_t pos = attr_str.find('='); if (pos == 0 || pos == std::string::npos || pos == attr_str.size() - 1) { NEARBY_LOGS(WARNING) << " found invalid text attribute: " << attr_str; + continue; } info.SetTxtRecord(attr_str.substr(0, pos), attr_str.substr(pos + 1));