GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: refactor crypto code with RAII cleanup · nodejs/node@4bd3b6e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_crypto_clienthello.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_crypto_clienthello.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto_clienthello.cc
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ bool ClientHelloParser::ParseRecordHeader(const uint8_t* data, size_t avail) {
7474

7575
void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
7676
ClientHello hello;
77+
bool failed = true;
78+
79+
OnScopeLeave cleanup([&]() {
80+
if (failed)
81+
End();
82+
});
7783

7884
// >= 5 + frame size bytes for frame parsing
7985
if (body_offset_ + frame_len_ > avail)
@@ -88,23 +94,23 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
8894
if (data[body_offset_ + 4] != 0x03 ||
8995
data[body_offset_ + 5] < 0x01 ||
9096
data[body_offset_ + 5] > 0x03) {
91-
goto fail;
97+
return;
9298
}
9399

94100
if (data[body_offset_] == kClientHello) {
95101
if (state_ == kTLSHeader) {
96102
if (!ParseTLSClientHello(data, avail))
97-
goto fail;
103+
return;
98104
} else {
99105
// We couldn't get here, but whatever
100-
goto fail;
106+
return;
101107
}
102108

103109
// Check if we overflowed (do not reply with any private data)
104110
if (session_id_ == nullptr ||
105111
session_size_ > 32 ||
106112
session_id_ + session_size_ > data + avail) {
107-
goto fail;
113+
return;
108114
}
109115
}
110116

@@ -116,10 +122,8 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
116122
hello.servername_ = servername_;
117123
hello.servername_size_ = static_cast<uint8_t>(servername_size_);
118124
onhello_cb_(cb_arg_, hello);
125+
failed = false;
119126
return;
120-
121-
fail:
122-
End();
123127
}
124128

125129

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.