From: Justin Erenkrantz Date: Sun, 11 Nov 2001 16:48:26 +0000 (+0000) Subject: apr_file_gets returns an apr_status_t not a char* and it returns X-Git-Tag: 2.0.29~187 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c87b1099624e8a64a6fad31b2ab8f75a96fef062;p=thirdparty%2Fapache%2Fhttpd.git 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 , Brian Pane Reviewed by: Justin Erenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91852 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 0ca0a08c4f7..24f9590d297 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.29-dev + *) Fix infinite loop in mod_cgid.c. + [Dale Ghent , Brian Pane ] + *) Add Debian layout. [Daniel Stone ] *) If shared modules are requested and mod_so is not available, diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 5d3c4e7006e..91bfd76bff4 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -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