Commit b11e11c2 authored by Jeff Trawick's avatar Jeff Trawick
Browse files

Empty out the brigade shared by ap_getline()/ap_get_client_block()

on error exit from ap_getline().  Some other code got upset because
the wrong data was in the brigade.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88552 13f79535-47bb-0310-9956-ffa450edef68
parent 4db84b39
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.15-dev

  *) Empty out the brigade shared by ap_getline()/ap_get_client_block()
     on error exit from ap_getline().  Some other code got upset because
     the wrong data was in the brigade.  [Greg Ames, Jeff Trawick]

  *) Handle ap_discard_request_body() being called more than once.
     [Greg Ames, Jeff Trawick]

+15 −6
Original line number Diff line number Diff line
@@ -519,8 +519,12 @@ AP_CORE_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold)

    while (1) {
        if (APR_BRIGADE_EMPTY(b)) {
            if (ap_get_brigade(c->input_filters, b, AP_MODE_BLOCKING) != APR_SUCCESS ||
            if ((retval = ap_get_brigade(c->input_filters, b, AP_MODE_BLOCKING)) != APR_SUCCESS ||
                APR_BRIGADE_EMPTY(b)) {
                apr_brigade_destroy(b);
                if (retval != APR_EOF && retval != APR_TIMEUP) {
                    ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, "ap_get_brigade() failed");
                }
                return -1;
            }
        }
@@ -530,10 +534,15 @@ AP_CORE_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold)
            continue;
        }
        retval = apr_bucket_read(e, &temp, &length, APR_BLOCK_READ);

        if (retval != APR_SUCCESS) {
            total = ((length < 0) && (total == 0)) ? -1 : total;
            break;
            apr_brigade_destroy(b);
            ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, "apr_bucket_read() failed");
            if (total) {
                break; /* report previously-read data to caller, do ap_xlate_proto_to_ascii() */
            }
            else {
                return -1;
            }
        }

        if ((looking_ahead) && (*temp != APR_ASCII_BLANK) && (*temp != APR_ASCII_TAB)) {