crypto: move field initialization to class#23610
crypto: move field initialization to class#23610theholla wants to merge 2 commits intonodejs:masterfrom
Conversation
src/node_crypto_clienthello.h
Outdated
| const uint8_t* session_id_; | ||
| uint16_t servername_size_; | ||
| const uint8_t* servername_; | ||
| uint8_t ocsp_request_; |
There was a problem hiding this comment.
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.
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.
@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.
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.
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_ts, and remove the static_cast when converting …
Either way, this might be better answered by @nodejs/crypto experts?
|
CI: https://ci.nodejs.org/job/node-test-pull-request/17779/ [scheduled] |
There was a problem hiding this comment.
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 <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
PR-URL: #23610 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
PR-URL: #23610 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
PR-URL: #23610 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
PR-URL: #23610 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
PR-URL: #23610 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Initialize fields of
ClientHelloParserin class rather than in constructor.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes