aboutsummaryrefslogtreecommitdiff
path: root/src/node_crypto_clienthello.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-05-16 12:47:51 +0400
committerFedor Indutny <fedor@indutny.com>2014-05-16 12:48:58 +0400
commit4a2c349473996fdf1b5f492ee27bf11c213b7747 (patch)
treee54f117ad4e77978194e7e781a7bb37fdcf9e805 /src/node_crypto_clienthello.cc
parent89cb740fc31f3be1c3af9fe787c7a405429ccac4 (diff)
downloadandroid-node-v8-4a2c349473996fdf1b5f492ee27bf11c213b7747.tar.gz
android-node-v8-4a2c349473996fdf1b5f492ee27bf11c213b7747.tar.bz2
android-node-v8-4a2c349473996fdf1b5f492ee27bf11c213b7747.zip
crypto: fix version check in hello parser
This is a follow up for 89cb740fc31f3be1c3af9fe787c7a405429ccac4
Diffstat (limited to 'src/node_crypto_clienthello.cc')
-rw-r--r--src/node_crypto_clienthello.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/node_crypto_clienthello.cc b/src/node_crypto_clienthello.cc
index 70603e95c5..ad0235343c 100644
--- a/src/node_crypto_clienthello.cc
+++ b/src/node_crypto_clienthello.cc
@@ -85,6 +85,12 @@ bool ClientHelloParser::ParseRecordHeader(const uint8_t* data, size_t avail) {
return true;
}
+#ifdef OPENSSL_NO_SSL2
+# define NODE_SSL2_VER_CHECK(buf) false
+#else
+# define NODE_SSL2_VER_CHECK(buf) ((buf)[0] == 0x00 && (buf)[1] == 0x02)
+#endif // OPENSSL_NO_SSL2
+
void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
ClientHello hello;
@@ -95,12 +101,10 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
// Skip unsupported frames and gather some data from frame
// Check hello protocol version
- if (!(data[body_offset_ + 4] == 0x03 && data[body_offset_ + 5] <= 0x03))
+ if (!(data[body_offset_ + 4] == 0x03 && data[body_offset_ + 5] <= 0x03) &&
+ !NODE_SSL2_VER_CHECK(data + body_offset_ + 4)) {
goto fail;
-#ifndef OPENSSL_NO_SSL2
- if (!(data[body_offset_ + 4] == 0x00 && data[body_offset_ + 5] == 0x02))
- goto fail;
-#endif
+ }
if (data[body_offset_] == kClientHello) {
if (state_ == kTLSHeader) {
@@ -141,6 +145,9 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
}
+#undef NODE_SSL2_VER_CHECK
+
+
void ClientHelloParser::ParseExtension(ClientHelloParser::ExtensionType type,
const uint8_t* data,
size_t len) {