Skip to content

Commit

Permalink
Make QR code parsing error out if the padding bits are not all 0.
Browse files Browse the repository at this point in the history
Right now we accept invalid QR codes with nonzero padding.
  • Loading branch information
bzbarsky-apple committed May 25, 2022
1 parent a3fdd05 commit e06a278
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 e06a278

Please sign in to comment.