]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Generic fix for PR#31759
authorNick Kew <niq@apache.org>
Thu, 21 Sep 2006 22:13:34 +0000 (22:13 +0000)
committerNick Kew <niq@apache.org>
Thu, 21 Sep 2006 22:13:34 +0000 (22:13 +0000)
If a handler returns a value that is neither reserved nor a valid
HTTP response code, log an error and substitute HTTP_INTERNAL_SERVER_ERROR.
Allow a handler to override this explicitly by setting a note.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@448711 13f79535-47bb-0310-9956-ffa450edef68

include/httpd.h
server/config.c

index 2fce9ebba88af148993b09987d03d20f73253574..601a8aaf34d9a1f3bd4d222c0e197265941df555 100644 (file)
@@ -529,6 +529,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 4e1799e7443af6f1031afb33c1422c82fc2d10f7..da6d6e23544e8e247715eb12ad3d88eaa0204517 100644 (file)
@@ -332,6 +332,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
@@ -382,6 +383,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;
 }