]> granicus.if.org Git - apache/commitdiff
apr_file_gets returns an apr_status_t not a char* and it returns
authorJustin Erenkrantz <jerenkrantz@apache.org>
Sun, 11 Nov 2001 16:48:26 +0000 (16:48 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Sun, 11 Nov 2001 16:48:26 +0000 (16:48 +0000)
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

CHANGES
modules/generators/mod_cgid.c

diff --git a/CHANGES b/CHANGES
index 0ca0a08c4f795fe19ad813c9267dd33c5288f6e6..24f9590d297402e999a0ddac6568be068630a19d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 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,
index 5d3c4e7006e5be4aeacf336e5b2f78fc2e151c61..91bfd76bff49a6a799f559936ea2ffcaa64eb176 100644 (file)
@@ -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