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

Tag testing in QRCodeSetupPayloadParser is wrong #10188

Closed
bzbarsky-apple opened this issue Oct 4, 2021 · 0 comments · Fixed by #13201
Closed

Tag testing in QRCodeSetupPayloadParser is wrong #10188

bzbarsky-apple opened this issue Oct 4, 2021 · 0 comments · Fixed by #13201
Labels
spec Mismatch between spec and implementation

Comments

@bzbarsky-apple
Copy link
Contributor

Problem

Code looks like this:

        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);

which is nonsense: the tag type tests need to happen on the tag, not the tag number.

But also, why are we allowing profile tags here anyway? The spec doesn't.

Proposed Solution

Align with spec, add tests.

@shana-apple

@bzbarsky-apple bzbarsky-apple added the spec Mismatch between spec and implementation label Oct 4, 2021
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Dec 22, 2021
The only reason this worked in any way is that TLV::IsProfileTag()
tests true for small integers, so the VerifyOrReturnError was a no-op,
even though we were testing IsContextTag() and IsProfileTag() on the
tag _number_, not the tag.

Per spec, only context tags are allowed here, so just allow those.

Fixes project-chip#10188
Damian-Nordic pushed a commit that referenced this issue Dec 22, 2021
The only reason this worked in any way is that TLV::IsProfileTag()
tests true for small integers, so the VerifyOrReturnError was a no-op,
even though we were testing IsContextTag() and IsProfileTag() on the
tag _number_, not the tag.

Per spec, only context tags are allowed here, so just allow those.

Fixes #10188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec Mismatch between spec and implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant