Skip to content

Commit

Permalink
crypto: replace gotos
Browse files Browse the repository at this point in the history
PR-URL: #23132
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
tniessen authored and targos committed Oct 3, 2018
1 parent 1a92335 commit 398c0e0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/node_crypto_clienthello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ bool ClientHelloParser::ParseRecordHeader(const uint8_t* data, size_t avail) {

void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
ClientHello hello;
bool failed = true;

OnScopeLeave cleanup([&]() {
if (failed)
End();
});

// >= 5 + frame size bytes for frame parsing
if (body_offset_ + frame_len_ > avail)
Expand All @@ -94,23 +88,23 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
if (data[body_offset_ + 4] != 0x03 ||
data[body_offset_ + 5] < 0x01 ||
data[body_offset_ + 5] > 0x03) {
return;
return End();
}

if (data[body_offset_] == kClientHello) {
if (state_ == kTLSHeader) {
if (!ParseTLSClientHello(data, avail))
return;
return End();
} else {
// We couldn't get here, but whatever
return;
return End();
}

// Check if we overflowed (do not reply with any private data)
if (session_id_ == nullptr ||
session_size_ > 32 ||
session_id_ + session_size_ > data + avail) {
return;
return End();
}
}

Expand All @@ -122,8 +116,6 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
hello.servername_ = servername_;
hello.servername_size_ = static_cast<uint8_t>(servername_size_);
onhello_cb_(cb_arg_, hello);
failed = false;
return;
}


Expand Down

0 comments on commit 398c0e0

Please sign in to comment.