Skip to content

Commit

Permalink
[srp] Fix SRP buffer sizes (#18139)
Browse files Browse the repository at this point in the history
The code for calculating buffer sizes used for SRP service
data wrongly assumed that commissionable services are used
only when the extended discovery is enabled. This wasn't
caught before because the extended discovery was enabled by
default on all Thread platforms (until recently).

Signed-off-by: Damian Krolik <[email protected]>
  • Loading branch information
Damian-Nordic authored May 6, 2022
1 parent 1f2e38e commit 5426850
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,13 @@ class GenericThreadStackManagerImpl_OpenThread
static constexpr uint8_t kDefaultDomainNameSize = 20;
static constexpr uint8_t kMaxDomainNameSize = 32;

#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
// Thread supports both operational and commissionable discovery, so buffers sizes must be worst case.
// SRP is used for both operational and commissionable services, so buffers sizes must be worst case.
static constexpr size_t kSubTypeMaxNumber = Dnssd::Common::kSubTypeMaxNumber;
static constexpr size_t kSubTypeTotalLength = Dnssd::Common::kSubTypeTotalLength;
static constexpr size_t kTxtMaxNumber =
std::max(Dnssd::CommissionAdvertisingParameters::kTxtMaxNumber, Dnssd::OperationalAdvertisingParameters::kTxtMaxNumber);
static constexpr size_t kTxtTotalValueLength = std::max(Dnssd::CommissionAdvertisingParameters::kTxtTotalValueSize,
Dnssd::OperationalAdvertisingParameters::kTxtTotalValueSize);
#else
// Thread only supports operational discovery.
static constexpr size_t kSubTypeMaxNumber = Dnssd::Operational::kSubTypeMaxNumber;
static constexpr size_t kSubTypeTotalLength = Dnssd::Operational::kSubTypeTotalLength;
static constexpr size_t kTxtMaxNumber = Dnssd::OperationalAdvertisingParameters::kTxtMaxNumber;
static constexpr size_t kTxtTotalValueLength = Dnssd::OperationalAdvertisingParameters::kTxtTotalValueSize;
#endif

static constexpr size_t kServiceBufferSize = Dnssd::Common::kInstanceNameMaxLength + 1 + // add null-terminator
Dnssd::kDnssdTypeAndProtocolMaxSize + 1 + // add null-terminator
Expand Down

0 comments on commit 5426850

Please sign in to comment.