From 5366041ee9421031217c2d0745d610fba6712358 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Wed, 2 Feb 2022 16:55:14 +0100 Subject: [PATCH] [AddressSanitizer] stack-use-after-scope in src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp (#14699) --- src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp index af39772765caf1..7d3bfce3a48917 100644 --- a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp @@ -679,32 +679,32 @@ FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertis AddCommonTxtEntries(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(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());