-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[PASESession] TLV Reading Fixes #37383
base: master
Are you sure you want to change the base?
Conversation
6fd15f1
to
59363de
Compare
PR #37383: Size comparison from f957643 to 59363de Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
59363de
to
fa04a11
Compare
PR #37383: Size comparison from 577b3f2 to fa04a11 Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
mExchangeCtxt.Value()->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters( | ||
GetRemoteSessionParameters()); | ||
|
||
err = tlvReader.Next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next requirement decouples the error set where we have:
- set it on line 554 OR
- set it on line 562 if we have a kResponderSessionParams OR
- set it on line 584 OR
- set it on line 592 if we have a kResponderSessionParams
Then check it on line 597
This feels hard to follow. Could we centralize the kResponderSessionParams handling? Could we extract it to a method that reads and rolls back if it cannot find it or have some other organization so that code always reads like err = SomeNext(); VerifyOr... (err == ...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted it to a method :ReadSessionParamsIfPresent
and made sure a VerifyOr is there after each call of it.
// happen in the future if additional elements are added to the specification. | ||
VerifyOrExit(err == CHIP_END_OF_TLV || err == CHIP_NO_ERROR, ); | ||
|
||
// Exit Container will fail (return CHIP_END_OF_TLV) if the received encoded message is not properly terminated with an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this comment in helping me read the code? It is true that ExitContainer returns a CHIP_ERROR so can fail. Why does this comment explicitly call out the CHIP_END_OF_TLV error and when it occurs?
Same comment for the copies of this below/throughout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify the importance of ExitContainer()? that having it serves as a check for a missing EndOfContainer terminator in the received message. should i reword it or remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this better?
// Exit Container will fail (return CHIP_END_OF_TLV) if the received encoded message is not properly terminated with an | |
// ExitContainer() acts as a safeguard to ensure that the received encoded message | |
// is properly terminated with an EndOfContainer TLV element. If the terminator is missing, CHIP_END_OF_TLV is returned. |
437da5b
to
3a79525
Compare
3a79525
to
843836f
Compare
PR #37383: Size comparison from 8ec9b41 to 843836f Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
Fixes TLV Reading of Containers often missed a call to ExitContainer #36959 : Making sure received encoded messages are properly terminated.
Adding Sanity Checks that the read TLV data has the expected number of bytes:
Adding symbolic TLV Tags
Testing