Fix extension length counter in client hello parsing.
authorKyle Nekritz <knekritz@fb.com>
Tue, 16 Aug 2016 16:53:26 +0000 (09:53 -0700)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Tue, 16 Aug 2016 17:08:26 +0000 (10:08 -0700)
Summary: Orvid noticed this was always throwing on a properly formated client hello, since the sig algs extension length isn't subtracted from the counter. This doesn't actually affect any behavior (except possibly a slight perf hit), but is pretty clowny.

Reviewed By: anirudhvr

Differential Revision: D3722887

fbshipit-source-id: 579993caac96da24fb567ab977b09fca519750a0

folly/io/async/AsyncSSLSocket.cpp

index b398e31c8bc85aeb618fdf979c88d4463250b668..721fb29510f1f827eb25b5c16928e1a84732ff48 100644 (file)
@@ -1651,6 +1651,7 @@ void AsyncSSLSocket::clientHelloParsingCallback(int written,
         extensionsLength -= 2;
         uint16_t extensionDataLength = cursor.readBE<uint16_t>();
         extensionsLength -= 2;
+        extensionsLength -= extensionDataLength;
 
         if (extensionType == ssl::TLSExtension::SIGNATURE_ALGORITHMS) {
           cursor.skip(2);
@@ -1666,7 +1667,6 @@ void AsyncSSLSocket::clientHelloParsingCallback(int written,
           }
         } else {
           cursor.skip(extensionDataLength);
-          extensionsLength -= extensionDataLength;
         }
       }
     }