Commit 54e14c11 authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

apr_file_gets returns an apr_status_t not a char* and it returns

APR_SUCCESS when it reads something (which is 0).

Two of the cases were doing while apr_file_gets > 0 which would cause
it to loop when it returned APR_EOF.  So, the valid check here is to
loop while we are receiving APR_SUCCESS.

Fix all of the other apr_file_gets to check APR_SUCCESS explicitly so
that it is obvious that we are checking an apr_status_t.  Yes,
0 == APR_SUCCESS, but it obviously wasn't clear to someone what it
was returning.

Submitted by:	Dale Ghent <daleg@elemental.org>,
                Brian Pane <bpane@pacbell.net>
Reviewed by:	Justin Erenkrantz


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91852 13f79535-47bb-0310-9956-ffa450edef68
parent 81466d7b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.29-dev

  *) Fix infinite loop in mod_cgid.c.  
     [Dale Ghent <daleg@elemental.org>, Brian Pane <bpane@pacbell.net>]

  *) Add Debian layout.  [Daniel Stone <daniel@sfarc.net>]

  *) If shared modules are requested and mod_so is not available,
+15 −8
Original line number Diff line number Diff line
@@ -764,10 +764,12 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
         (apr_file_open(&f, conf->logname, 
                  APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) { 
        /* Soak up script output */ 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0) 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                             script_in) == APR_SUCCESS) 
            continue; 
        if (script_err) {
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0) 
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                                 script_err) == APR_SUCCESS) 
                continue; 
        }
        return ret; 
@@ -804,19 +806,22 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
    if (sbuf && *sbuf) 
        apr_file_printf(f, "%s\n", sbuf); 

    if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0) { 
    if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == APR_SUCCESS) { 
        apr_file_puts("%stdout\n", f); 
        apr_file_puts(argsbuffer, f); 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0) 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                             script_in) == APR_SUCCESS) 
            apr_file_puts(argsbuffer, f); 
        apr_file_puts("\n", f); 
    } 

    if (script_err) {
        if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0) { 
        if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                          script_err) == APR_SUCCESS) { 
            apr_file_puts("%stderr\n", f); 
            apr_file_puts(argsbuffer, f); 
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0) 
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                                 script_err) == APR_SUCCESS) 
                apr_file_puts(argsbuffer, f); 
            apr_file_puts("\n", f); 
        } 
@@ -990,7 +995,8 @@ static int cgid_handler(request_rec *r)
        if (location && location[0] == '/' && r->status == 200) { 

            /* Soak up all the script output */ 
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, tempsock) > 0) { 
            while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                                 tempsock) == APR_SUCCESS) { 
                continue; 
            } 
            /* This redirect needs to be a GET no matter what the original 
@@ -1196,7 +1202,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, char *comman
        char argsbuffer[HUGE_STRING_LEN]; 

        /* Soak up all the script output */ 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, tempsock) > 0) { 
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, 
                             tempsock) == APR_SUCCESS) { 
            continue; 
        } 
        /* This redirect needs to be a GET no matter what the original