summaryrefslogtreecommitdiff
path: root/gtests/ssl_gtest
diff options
context:
space:
mode:
authorLeander Schwarz <lschwarz@mozilla.com>2022-06-10 10:22:35 +0000
committerLeander Schwarz <lschwarz@mozilla.com>2022-06-10 10:22:35 +0000
commit1e910430010139a54808439998080804126a51b9 (patch)
tree6dcf5ac966ef86eaf50f1dad5d21ff98362d2665 /gtests/ssl_gtest
parentd91c4ab506ab671e0d73d69d0a66b5b41147155a (diff)
downloadnss-hg-1e910430010139a54808439998080804126a51b9.tar.gz
Bug 1765383 - GatherBuffer: Reduced plaintext buffer allocations by allocating it on initialization. Replaced redundant code with assert. Debug builds: Added buffer freeing/allocation for each record. r=djackson
Differential Revision: https://phabricator.services.mozilla.com/D144034
Diffstat (limited to 'gtests/ssl_gtest')
-rw-r--r--gtests/ssl_gtest/ssl_gather_unittest.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/gtests/ssl_gtest/ssl_gather_unittest.cc b/gtests/ssl_gtest/ssl_gather_unittest.cc
index cdcdf5626..2b0b722ae 100644
--- a/gtests/ssl_gtest/ssl_gather_unittest.cc
+++ b/gtests/ssl_gtest/ssl_gather_unittest.cc
@@ -126,4 +126,31 @@ TEST_F(GatherV2ClientHelloTest, GatherEmptyV2RecordShortHeader) {
ConnectExpectMalformedClientHello(buffer);
}
+/* Test correct gather buffer clearing/freeing and (re-)allocation.
+ *
+ * Freeing and (re-)allocation of the gather buffers after reception of single
+ * records is only done in DEBUG builds. Normally they are created and
+ * destroyed with the SSL socket.
+ *
+ * TLS 1.0 record splitting leads to implicit complete read of the data.
+ *
+ * The NSS DTLS impelmentation does not allow partial reads
+ * (see sslsecur.c, line 535-543). */
+TEST_P(TlsConnectStream, GatherBufferPartialReadTest) {
+ EnsureTlsSetup();
+ Connect();
+
+ client_->SendData(1000);
+
+ if (version_ > SSL_LIBRARY_VERSION_TLS_1_0) {
+ for (unsigned i = 1; i <= 20; i++) {
+ server_->ReadBytes(50);
+ ASSERT_EQ(server_->received_bytes(), 50U * i);
+ }
+ } else {
+ server_->ReadBytes(50);
+ ASSERT_EQ(server_->received_bytes(), 1000U);
+ }
+}
+
} // namespace nss_test