Skip to content

Commit d3c39a9

Browse files
Reinstate guard, abandon SSL_MODE_AUTO_RETRY
1 parent c75e5cb commit d3c39a9

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

include/openssl/ssl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,6 @@ OPENSSL_EXPORT uint32_t SSL_get_options(const SSL *ssl);
869869
// session resumption is used for a given SSL*.
870870
#define SSL_MODE_NO_SESSION_CREATION 0x00000200L
871871

872-
// TODO [childw]
873-
#define SSL_MODE_AUTO_RETRY 0x00000004L
874-
875872
// SSL_MODE_SEND_FALLBACK_SCSV sends TLS_FALLBACK_SCSV in the ClientHello.
876873
// To be set only by applications that reconnect with a downgraded protocol
877874
// version; see RFC 7507 for details.
@@ -5278,6 +5275,7 @@ DEFINE_STACK_OF(SSL_COMP)
52785275

52795276
// The following flags do nothing and are included only to make it easier to
52805277
// compile code with BoringSSL.
5278+
#define SSL_MODE_AUTO_RETRY 0
52815279
#define SSL_MODE_RELEASE_BUFFERS 0
52825280
#define SSL_MODE_SEND_CLIENTHELLO_TIME 0
52835281
#define SSL_MODE_SEND_SERVERHELLO_TIME 0

ssl/ssl_lib.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,7 @@ static int ssl_read_impl(SSL *ssl) {
10271027
&alert, ssl->s3->read_buffer.span());
10281028
bool retry;
10291029
int bio_ret = ssl_handle_open_record(ssl, &retry, ret, consumed, alert);
1030-
1031-
if (bio_ret == 0 && retry && (ssl->ctx->mode & SSL_MODE_AUTO_RETRY)) {
1032-
continue;
1033-
} else if (bio_ret <= 0) {
1030+
if (bio_ret <= 0) {
10341031
return bio_ret;
10351032
}
10361033
if (!retry) {
@@ -1391,8 +1388,11 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
13911388
}
13921389
// An EOF was observed which violates the protocol, and the underlying
13931390
// transport does not participate in the error queue. Bubble up to the
1394-
// caller.
1395-
return SSL_ERROR_SYSCALL;
1391+
// caller. Do not consider retryable |rwstate| EOF.
1392+
if (ssl->s3->rwstate != SSL_ERROR_WANT_READ
1393+
&& ssl->s3->rwstate != SSL_ERROR_WANT_WRITE) {
1394+
return SSL_ERROR_SYSCALL;
1395+
}
13961396
}
13971397

13981398
switch (ssl->s3->rwstate) {

ssl/ssl_test.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10491,26 +10491,28 @@ TEST(SSLTest, IntermittentEmptyRead) {
1049110491
SSL_set0_rbio(client.get(), rbio_empty.release());
1049210492

1049310493
// Server writes some data to the client
10494-
const uint8_t data[1] = {0};
10495-
int ret = SSL_write(server.get(), data, (int) sizeof(data));
10496-
EXPECT_EQ(ret, (int) sizeof(data));
10494+
const uint8_t write_data[] = {1, 2, 3};
10495+
int ret = SSL_write(server.get(), write_data, (int) sizeof(write_data));
10496+
EXPECT_EQ(ret, (int) sizeof(write_data));
1049710497
EXPECT_EQ(SSL_get_error(server.get(), ret), SSL_ERROR_NONE);
1049810498

1049910499
// On empty read, client should still want a read so caller will retry
10500-
uint8_t buf[1];
10501-
ret = SSL_read(client.get(), buf, sizeof(buf));
10500+
uint8_t read_data[] = {0, 0, 0};
10501+
ret = SSL_read(client.get(), read_data, sizeof(read_data));
1050210502
EXPECT_EQ(ret, 0);
1050310503
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_WANT_READ);
1050410504

1050510505
// Reset client rbio, read should succeed
1050610506
SSL_set0_rbio(client.get(), client_rbio.release());
10507-
ret = SSL_read(client.get(), buf, sizeof(buf));
10508-
EXPECT_EQ(ret, (int) sizeof(buf));
10507+
ret = SSL_read(client.get(), read_data, sizeof(read_data));
10508+
EXPECT_EQ(ret, (int) sizeof(write_data));
10509+
EXPECT_EQ(OPENSSL_memcmp(read_data, write_data, sizeof(write_data)), 0);
1050910510
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_NONE);
1051010511

10511-
ret = SSL_read(client.get(), buf, sizeof(buf));
10512-
EXPECT_LE(ret, 0);
10513-
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_SSL);
10512+
// Subsequent attempts to read should fail
10513+
ret = SSL_read(client.get(), read_data, sizeof(read_data));
10514+
EXPECT_LT(ret, 0);
10515+
EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_WANT_READ);
1051410516
}
1051510517

1051610518
// Test that |SSL_shutdown|, when quiet shutdown is enabled, simulates receiving

0 commit comments

Comments
 (0)