Skip to content

Commit

Permalink
[AddressSanitizer] stack-use-after-scope in src/lib/dnssd/Advertiser_…
Browse files Browse the repository at this point in the history
…ImplMinimalMdns.cpp (#14699)
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 2, 2024
1 parent 36b1766 commit 5366041
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,32 +679,32 @@ FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertis
AddCommonTxtEntries<CommissionAdvertisingParameters>(params, commonStorage, txtFields, numTxtFields);

// the following sub types only apply to commissionable node advertisements
char txtDiscriminator[chip::Dnssd::kKeyLongDiscriminatorMaxLength + 3];
char txtCommissioningMode[chip::Dnssd::kKeyCommissioningModeMaxLength + 4];
char txtRotatingDeviceId[chip::Dnssd::kKeyRotatingDeviceIdMaxLength + 4];
char txtPairingHint[chip::Dnssd::kKeyPairingInstructionMaxLength + 4];
char txtPairingInstr[chip::Dnssd::kKeyPairingInstructionMaxLength + 4];
if (params.GetCommissionAdvertiseMode() == CommssionAdvertiseMode::kCommissionableNode)
{
// a discriminator always exists
char txtDiscriminator[chip::Dnssd::kKeyLongDiscriminatorMaxLength + 3];
snprintf(txtDiscriminator, sizeof(txtDiscriminator), "D=%d", params.GetLongDiscriminator());
txtFields[numTxtFields++] = txtDiscriminator;

char txtCommissioningMode[chip::Dnssd::kKeyCommissioningModeMaxLength + 4];
snprintf(txtCommissioningMode, sizeof(txtCommissioningMode), "CM=%d", static_cast<int>(params.GetCommissioningMode()));
txtFields[numTxtFields++] = txtCommissioningMode;

char txtRotatingDeviceId[chip::Dnssd::kKeyRotatingDeviceIdMaxLength + 4];
if (params.GetRotatingDeviceId().HasValue())
{
snprintf(txtRotatingDeviceId, sizeof(txtRotatingDeviceId), "RI=%s", params.GetRotatingDeviceId().Value());
txtFields[numTxtFields++] = txtRotatingDeviceId;
}

char txtPairingHint[chip::Dnssd::kKeyPairingInstructionMaxLength + 4];
if (params.GetPairingHint().HasValue())
{
snprintf(txtPairingHint, sizeof(txtPairingHint), "PH=%d", params.GetPairingHint().Value());
txtFields[numTxtFields++] = txtPairingHint;
}

char txtPairingInstr[chip::Dnssd::kKeyPairingInstructionMaxLength + 4];
if (params.GetPairingInstruction().HasValue())
{
snprintf(txtPairingInstr, sizeof(txtPairingInstr), "PI=%s", params.GetPairingInstruction().Value());
Expand Down

0 comments on commit 5366041

Please sign in to comment.