Skip to content

Commit

Permalink
Make QR code parsing error out if the padding bits are not all 0. (#1…
Browse files Browse the repository at this point in the history
…8809)

Right now we accept invalid QR codes with nonzero padding.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 2, 2022
1 parent 6d71e46 commit 1389372
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/setup_payload/QRCodeSetupPayloadParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ CHIP_ERROR QRCodeSetupPayloadParser::populatePayload(SetupPayload & outPayload)
outPayload.setUpPINCode = static_cast<uint32_t>(dest);

ReturnErrorOnFailure(readBits(buf, indexToReadFrom, dest, kPaddingFieldLengthInBits));
if (dest != 0)
{
ChipLogError(SetupPayload, "Payload padding bits are not all 0: 0x%x", static_cast<unsigned>(dest));
return CHIP_ERROR_INVALID_ARGUMENT;
}

return populateTLV(outPayload, buf, indexToReadFrom);
}
Expand Down

0 comments on commit 1389372

Please sign in to comment.