Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AddressSanitizer] stack-use-after-scope in src/lib/dnssd/Advertiser_… #14699

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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