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

Fix broken tag handling in QRCodeSetupPayloadParser. #13201

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
13 changes: 7 additions & 6 deletions src/setup_payload/QRCodeSetupPayloadParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ CHIP_ERROR QRCodeSetupPayloadParser::retrieveOptionalInfos(SetupPayload & outPay
continue;
}

const uint8_t tag = static_cast<uint8_t>(TLV::TagNumFromTag(reader.GetTag()));
VerifyOrReturnError(TLV::IsContextTag(tag) == true || TLV::IsProfileTag(tag) == true, CHIP_ERROR_INVALID_TLV_TAG);
TLV::Tag tag = reader.GetTag();
VerifyOrReturnError(TLV::IsContextTag(tag), CHIP_ERROR_INVALID_TLV_TAG);
const uint8_t tagNumber = static_cast<uint8_t>(TLV::TagNumFromTag(tag));

optionalQRCodeInfoType elemType = optionalQRCodeInfoTypeUnknown;
if (type == TLV::kTLVType_UTF8String)
Expand All @@ -204,21 +205,21 @@ CHIP_ERROR QRCodeSetupPayloadParser::retrieveOptionalInfos(SetupPayload & outPay
}
if (type == TLV::kTLVType_SignedInteger || type == TLV::kTLVType_UnsignedInteger)
{
elemType = outPayload.getNumericTypeFor(tag);
elemType = outPayload.getNumericTypeFor(tagNumber);
}

if (IsCHIPTag(tag))
if (IsCHIPTag(tagNumber))
{
OptionalQRCodeInfoExtension info;
info.tag = tag;
info.tag = tagNumber;
ReturnErrorOnFailure(retrieveOptionalInfo(reader, info, elemType));

ReturnErrorOnFailure(outPayload.addOptionalExtensionData(info));
}
else
{
OptionalQRCodeInfo info;
info.tag = tag;
info.tag = tagNumber;
ReturnErrorOnFailure(retrieveOptionalInfo(reader, info, elemType));

ReturnErrorOnFailure(outPayload.addOptionalVendorData(info));
Expand Down