]> granicus.if.org Git - apache/commitdiff
* Prevent segfaults in handlers by ensuring that r->handler != NULL.
authorRuediger Pluem <rpluem@apache.org>
Sat, 31 Jan 2009 20:35:03 +0000 (20:35 +0000)
committerRuediger Pluem <rpluem@apache.org>
Sat, 31 Jan 2009 20:35:03 +0000 (20:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@739598 13f79535-47bb-0310-9956-ffa450edef68

server/config.c

index 189cea522580529fd22f81ffdd3ec9d7a6dcf2f4..564cf6d5efd1cbb4344307cc403fe1b9f59f0f50 100644 (file)
@@ -324,6 +324,12 @@ static int ap_invoke_filter_init(ap_filter_t *filters)
     return OK;
 }
 
+/*
+ * TODO: Move this to an appropriate include file and possibly prefix it
+ * with AP_.
+ */
+#define DEFAULT_HANDLER_NAME ""
+
 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
 {
     const char *handler;
@@ -355,19 +361,24 @@ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
         return result;
     }
 
-    if (!r->handler && r->content_type) {
-        handler = r->content_type;
-        if ((p=ap_strchr_c(handler, ';')) != NULL) {
-            char *new_handler = (char *)apr_pmemdup(r->pool, handler,
-                                                    p - handler + 1);
-            char *p2 = new_handler + (p - handler);
-            handler = new_handler;
+    if (!r->handler) {
+        if (r->content_type) {
+            handler = r->content_type;
+            if ((p=ap_strchr_c(handler, ';')) != NULL) {
+                char *new_handler = (char *)apr_pmemdup(r->pool, handler,
+                                                        p - handler + 1);
+                char *p2 = new_handler + (p - handler);
+                handler = new_handler;
 
-            /* exclude media type arguments */
-            while (p2 > handler && p2[-1] == ' ')
-                --p2; /* strip trailing spaces */
+                /* exclude media type arguments */
+                while (p2 > handler && p2[-1] == ' ')
+                    --p2; /* strip trailing spaces */
 
-            *p2='\0';
+                *p2='\0';
+            }
+        }
+        else {
+            handler = DEFAULT_HANDLER_NAME;
         }
 
         r->handler = handler;