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 <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • 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.