Skip to content

Commit 6e275f6

Browse files
[nrf fromlist][dnssd] Fixed buffer sizes for dns names
The DNS browse for vendor id subtype does not work, as full name does not fit in the provided buffer. By the way of investigating this issue couple of other issues were found: * Started to use full service name including subtypes for dns browse results handling in Thread implementation * Fixed kDnssdFullTypeAndProtocolMaxSize that did not include _sub phrase Signed-off-by: Kamil Kasperczyk <[email protected]>
1 parent 4cc25d5 commit 6e275f6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/lib/dnssd/platform/Dnssd.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ namespace Dnssd {
4545
static constexpr size_t kDnssdProtocolTextMaxSize = std::max(sizeof(kOperationalProtocol), sizeof(kCommissionProtocol)) - 1;
4646
static constexpr size_t kDnssdTypeMaxSize =
4747
std::max({ sizeof(kCommissionableServiceName), sizeof(kOperationalServiceName), sizeof(kCommissionerServiceName) }) - 1;
48-
static constexpr uint8_t kDnssdTypeAndProtocolMaxSize = kDnssdTypeMaxSize + kDnssdProtocolTextMaxSize + 1; // <type>.<protocol>
49-
static constexpr uint16_t kDnssdTextMaxSize = 64;
50-
static constexpr uint8_t kDnssdFullTypeAndProtocolMaxSize = Common::kSubTypeMaxLength + /* '.' */ 1 + kDnssdTypeAndProtocolMaxSize;
48+
static constexpr uint8_t kDnssdTypeAndProtocolMaxSize = kDnssdTypeMaxSize + kDnssdProtocolTextMaxSize + 1; // <type>.<protocol>
49+
static constexpr uint16_t kDnssdTextMaxSize = 64;
50+
static constexpr uint8_t kDnssdFullTypeAndProtocolMaxSize =
51+
Common::kSubTypeMaxLength + /* '.' */ 1 + sizeof(kSubtypeServiceNamePart) + kDnssdTypeAndProtocolMaxSize;
5152

5253
enum class DnssdServiceProtocol : uint8_t
5354
{

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnDnsBrowseResult(otEr
18811881
{
18821882
CHIP_ERROR error;
18831883
// type buffer size is kDnssdTypeAndProtocolMaxSize + . + kMaxDomainNameSize + . + termination character
1884-
char type[Dnssd::kDnssdTypeAndProtocolMaxSize + SrpClient::kMaxDomainNameSize + 3];
1884+
char type[Dnssd::kDnssdFullTypeAndProtocolMaxSize + SrpClient::kMaxDomainNameSize + 3];
18851885
// hostname buffer size is kHostNameMaxLength + . + kMaxDomainNameSize + . + termination character
18861886
char hostname[Dnssd::kHostNameMaxLength + SrpClient::kMaxDomainNameSize + 3];
18871887
// secure space for the raw TXT data in the worst-case scenario relevant for Matter:

0 commit comments

Comments
 (0)