]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_ssl: Add the missing SSL_ERROR_WANT_WRITE case in the SSL_read. Make
authorGraham Leggett <minfrin@apache.org>
Sat, 22 Jan 2022 20:05:21 +0000 (20:05 +0000)
committerGraham Leggett <minfrin@apache.org>
Sat, 22 Jan 2022 20:05:21 +0000 (20:05 +0000)
sure the sense is correctly specified in response to SSL_ERROR_WANT_READ
and SSL_ERROR_WANT_WRITE so we don't poll for the wrong case.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897353 13f79535-47bb-0310-9956-ffa450edef68

modules/ssl/ssl_engine_io.c

index 8658ed44e70fe798bb16a226078dd88431827775..c693ad2a3a259fb3c848b9083523f32238e06081 100644 (file)
@@ -323,6 +323,7 @@ typedef struct {
 } char_buffer_t;
 
 typedef struct {
+    conn_rec *c;
     SSL *ssl;
     BIO *bio_out;
     ap_filter_t *f;
@@ -795,6 +796,28 @@ static apr_status_t ssl_io_input_read(bio_filter_in_ctx_t *inctx,
                  * (This is usually the case when the client forces an SSL
                  * renegotiation which is handled implicitly by OpenSSL.)
                  */
+                inctx->c->cs->sense = CONN_SENSE_WANT_READ;
+                inctx->rc = APR_EAGAIN;
+
+                if (*len > 0) {
+                    inctx->rc = APR_SUCCESS;
+                    break;
+                }
+                if (inctx->block == APR_NONBLOCK_READ) {
+                    break;
+                }
+                continue;  /* Blocking and nothing yet?  Try again. */
+            }
+            if (ssl_err == SSL_ERROR_WANT_WRITE) {
+                /*
+                 * If OpenSSL wants to write during read, and we were
+                 * nonblocking, report as an EAGAIN.  Otherwise loop,
+                 * pulling more data from network filter.
+                 *
+                 * (This is usually the case when the client forces an SSL
+                 * renegotiation which is handled implicitly by OpenSSL.)
+                 */
+                inctx->c->cs->sense = CONN_SENSE_WANT_WRITE;
                 inctx->rc = APR_EAGAIN;
 
                 if (*len > 0) {
@@ -2303,6 +2326,7 @@ static void ssl_io_input_add_filter(ssl_filter_ctx_t *filter_ctx, conn_rec *c,
 #endif
     BIO_set_data(filter_ctx->pbioRead, (void *)inctx);
 
+    inctx->c = c;
     inctx->ssl = ssl;
     inctx->bio_out = filter_ctx->pbioWrite;
     inctx->f = filter_ctx->pInputFilter;