Commit 641e707e authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

- Add AP_MODE_SPECULATIVE support to mod_ssl

- Protect mod_ssl from dealing with modes it doesn't recognize.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/ssl@92968 13f79535-47bb-0310-9956-ffa450edef68
parent 1d5a405f
Loading
Loading
Loading
Loading
+14 −3
Changes for ssl_engine_io.c: 14 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -646,6 +646,12 @@ static apr_status_t ssl_io_input_read(ssl_io_input_ctx_t *ctx,

    if ((bytes = char_buffer_read(&ctx->cbuf, buf, wanted))) {
        *len = bytes;
        if (ctx->inbio.mode == AP_MODE_SPECULATIVE) {
            /* We want to rollback this read. */
            ctx->cbuf.value -= bytes;
            ctx->cbuf.length += bytes;
            return APR_SUCCESS;
        } 
        if ((*len >= wanted) || ctx->inbio.mode == AP_MODE_GETLINE) {
            return APR_SUCCESS;
        }
@@ -655,6 +661,9 @@ static apr_status_t ssl_io_input_read(ssl_io_input_ctx_t *ctx,

    if (rc > 0) {
        *len += rc;
        if (ctx->inbio.mode == AP_MODE_SPECULATIVE) {
            char_buffer_write(&ctx->cbuf, buf, rc);
        }
    }

    return ctx->inbio.rc;
@@ -736,8 +745,9 @@ static apr_status_t ssl_io_filter_Input(ap_filter_t *f,
    apr_off_t bytes = *readbytes;
    int is_init = (mode == AP_MODE_INIT);

    /* XXX: we don't currently support peek or readbytes == -1 */
    if (mode == AP_MODE_EATCRLF || *readbytes == -1) {
    /* XXX: we don't currently support anything other than these modes. */
    if (mode != AP_MODE_READBYTES && mode != AP_MODE_GETLINE && 
        mode != AP_MODE_SPECULATIVE && mode != AP_MODE_INIT) {
        return APR_ENOTIMPL;
    }

@@ -762,7 +772,8 @@ static apr_status_t ssl_io_filter_Input(ap_filter_t *f,
        return APR_SUCCESS;
    }

    if (ctx->inbio.mode == AP_MODE_READBYTES) {
    if (ctx->inbio.mode == AP_MODE_READBYTES || 
        ctx->inbio.mode == AP_MODE_SPECULATIVE) {
        /* Protected from truncation, bytes < MAX_SIZE_T */
        if (bytes < len) {
            len = (apr_size_t)bytes;