]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Deal with the widespread use of apr_status_t return values
authorGraham Leggett <minfrin@apache.org>
Thu, 12 Oct 2006 22:55:03 +0000 (22:55 +0000)
committerGraham Leggett <minfrin@apache.org>
Thu, 12 Oct 2006 22:55:03 +0000 (22:55 +0000)
as HTTP status codes, as documented in PR#31759 (a bug shared by
the default handler, mod_cgi, mod_cgid, mod_proxy, and probably
others).

+1: niq, minfrin, rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@463488 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
include/httpd.h
server/config.c

diff --git a/CHANGES b/CHANGES
index e2e07734e718abd934855935202242f53c92cd1c..7d02e1b0bb54c847266c7c2384ab443220887354 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+  *) core: Deal with the widespread use of apr_status_t return values
+     as HTTP status codes, as documented in PR#31759 (a bug shared by
+     the default handler, mod_cgi, mod_cgid, mod_proxy, and probably
+     others). [Jeff Trawick, Ruediger Pluem, Joe Orton]
+
   *) mod_ext_filter: Handle filter names which include capital letters.
      PR 40323.  [Jeff Trawick]
 
diff --git a/STATUS b/STATUS
index 5d503229a3edfe2c87af6770ba8a20f8dab67500..d609205b1869a46348ea911415ea7708532fbfda 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -77,13 +77,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * core: Deal with the widespread use of apr_status_t return values
-      as HTTP status codes, as documented in PR#31759 (a bug shared by
-      the default handler, mod_cgi, mod_cgid, mod_proxy, and probably
-      others).
-      http://svn.apache.org/viewvc?view=rev&revision=448711
-      +1: niq, minfrin, rpluem
-
     * mod_cache: Don't cache requests with a expires date in the past;
       otherwise mod_cache will always try to cache the URL. This bug
       might lead to numerous rename() errors on win32 if the URL was
index 76ce0de2b9d3170117cb3e6a23e43602bdeec714..d4f61c4f99aabf8ebd093b54b6292d3d7e0870f7 100644 (file)
@@ -538,6 +538,8 @@ AP_DECLARE(const char *) ap_get_server_built(void);
 #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
 /** is the status code a server error  */
 #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
+/** is the status code a (potentially) valid response code?  */
+#define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600))
 
 /** should the status code drop the connection */
 #define ap_status_drops_connection(x) \
index 8eed98b0638e86472f2cb0e3154cea4832cb03d6..d10f4afe26458ec5d985cab8261f6171a94e496f 100644 (file)
@@ -326,6 +326,7 @@ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
     const char *p;
     int result;
     const char *old_handler = r->handler;
+    const char *ignore;
 
     /*
      * The new insert_filter stage makes the most sense here.  We only use
@@ -376,6 +377,22 @@ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
             "handler \"%s\" not found for: %s", r->handler, r->filename);
     }
+    if ((result != OK) && (result != DONE) && (result != DECLINED)
+        && !ap_is_HTTP_VALID_RESPONSE(result)) {
+        /* If a module is deliberately returning something else
+         * (request_rec in non-HTTP or proprietary extension?)
+         * let it set a note to allow it explicitly.
+         * Otherwise, a return code that is neither reserved nor HTTP
+         * is a bug, as in PR#31759.
+         */
+        ignore = apr_table_get(r->notes, "HTTP_IGNORE_RANGE");
+        if (!ignore) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                          "Handler for %s returned invalid result code %d",
+                          r->handler, result);
+            result = HTTP_INTERNAL_SERVER_ERROR;
+        }
+    }
 
     return result == DECLINED ? HTTP_INTERNAL_SERVER_ERROR : result;
 }