-
Notifications
You must be signed in to change notification settings - Fork 30k
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
crypto: move field initialization to class #23610
crypto: move field initialization to class #23610
Conversation
src/node_crypto_clienthello.h
Outdated
size_t extension_offset_; | ||
size_t frame_len_ = 0; | ||
size_t body_offset_ = 0; | ||
size_t extension_offset_ = 0; | ||
uint8_t session_size_; | ||
const uint8_t* session_id_; | ||
uint16_t servername_size_; | ||
const uint8_t* servername_; | ||
uint8_t ocsp_request_; |
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 think you also need/want to add default initializers here, for the 5 that are later applied to ClientHello
directly?
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've updated the PR and moved the default initializers from ClientHello
to ClientHelloParser
, which I believe is what was needed in the first place.
Thanks for catching that. I'm not very familiar with C++ and appreciate the keen eye!
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.
@theholla Just for context – I don’t think there was anything wrong with adding the initializers to ClientHello
, as long as ClientHelloParser
has all initializers that were previously in its own constructor :)
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.
That's good to know, thanks! While you're here, I wonder if you see any issues with the two fields that are listed as one type in one class, and another in the next? Both servername_size
and ocsp_request
are listed as different types between ClientHello
and ClientHelloParser
.
class ClientHelloParser {
class ClientHello {
private:
uint8_t servername_size_;
int ocsp_request_;
};
private:
uint16_t servername_size_ = 0;
uint8_t ocsp_request_ = 0;
}
This predated the PR but stood out to me as a possible issue.
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.
Puh … that’s a good question.
For ocsp_request_
, I searched for instances of that in the source code, and it seems like the only values are 0
and 1
– I think you could change the type in one so it matches the other, if you like. (I could totally be wrong about this being a “boolean“, though…)
For servername_size_
, I’m not sure. It looks to me like we wouldn’t do anything wrong by making both fields uint16_t
s, and remove the static_cast
when converting …
Either way, this might be better answered by @nodejs/crypto experts?
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.
Thanks!
CI: https://ci.nodejs.org/job/node-test-pull-request/17779/ [scheduled] |
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.
LGTM.
Should be squashed (could be done at landing, I presume).
As a side note, it's interesting that tls_ticket_size_ = 0
appears unused, as it's immediately set to -1
in Reset()
which is called directly from the constructor. But I would suggest not to touch that in this PR for now, this PR looks good.
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/17798 |
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/17820/ |
Collaborators, please 👍 here to approve fast-tracking. |
Landed in 98afca9 Thanks for the contribution! 🎉 (If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.) |
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
PR-URL: #23610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]>
Initialize fields of
ClientHelloParser
in class rather than in constructor.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes