From: Nick Kew Date: Thu, 21 Sep 2006 22:13:34 +0000 (+0000) Subject: Generic fix for PR#31759 X-Git-Tag: 2.3.0~2127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51102dd25ab124d527a78f51c4d27350009d617f;p=thirdparty%2Fapache%2Fhttpd.git Generic fix for PR#31759 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 --- diff --git a/include/httpd.h b/include/httpd.h index 2fce9ebba88..601a8aaf34d 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -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) \ diff --git a/server/config.c b/server/config.c index 4e1799e7443..da6d6e23544 100644 --- a/server/config.c +++ b/server/config.c @@ -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; }