crypto/tls: make checkForResumption side-effect free#3
Open
SparrowLii wants to merge 1 commit intoMabinGo:masterfrom
Open
crypto/tls: make checkForResumption side-effect free#3SparrowLii wants to merge 1 commit intoMabinGo:masterfrom
SparrowLii wants to merge 1 commit intoMabinGo:masterfrom
Conversation
Fixes golang#39406 When use checkForResumption() function it could be side-effect sometime. 1. hs.sessionState will be changed and retained although the function return false. 2. hs.suite will be changed and retained when the statements below return false. So we should use a local variable, cilentSessionState, to replace hs.sessionState in the function. And move the set-suite statements down to avoid being changed too early.
surechen
reviewed
Jul 28, 2020
| return false | ||
| } | ||
|
|
||
| // Check that we also support the ciphersuite from the session. |
Author
There was a problem hiding this comment.
有影响,这样做避免了给hs.suite赋值以后,之后的函数语句又返回了false结果,导致suite维护了一个无用的值。保持了函数的side-effect free。
surechen
reviewed
Jul 28, 2020
| } | ||
|
|
||
| // Check that we also support the ciphersuite from the session. | ||
| hs.suite = selectCipherSuite([]uint16{clientSessionState.cipherSuite}, |
Author
There was a problem hiding this comment.
这种情况下只可能是suite==nil,然后返回false,表示没有找到合适的加解密工具版本。suite之前就是nil,没有变化
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes golang#39406
When use checkForResumption() function it could be side-effect sometime.
So we should use a local variable, cilentSessionState, to replace hs.sessionState in the function. And move the set-suite statements down to avoid being changed too early.
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
Please ensure you adhere to every item in this list.
More info can be found at https://github.com/golang/go/wiki/CommitMessage
net/http: frob the quux before blarfing"This change modifies Go to ___________"
really needed (ASCII art, table, or long link)
Fixes #1234orUpdates #1234(the latter if this is not a complete fix) to this comment
golang/goyou can use theowner/repo#issue_numbersyntax:Fixes golang/tools#1234Our Gerrit server & GitHub bots enforce CLA compliance instead.