On 01/30/2009 08:12 PM, field...@apache.org wrote:
> Author: fielding
> Date: Fri Jan 30 19:12:51 2009
> New Revision: 739382
> 
> URL: http://svn.apache.org/viewvc?rev=739382&view=rev
> Log:
> Disabled DefaultType directive and removed ap_default_type()
> from core.  We now exclude Content-Type from responses for which
> a media type has not been configured via mime.types, AddType,
> ForceType, or some other mechanism.  MMN major bump to NZ time.
> 
> PR: 13986
> 
> 
> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/include/ap_mmn.h
>     httpd/httpd/trunk/include/http_core.h
>     httpd/httpd/trunk/include/http_protocol.h
>     httpd/httpd/trunk/include/httpd.h
>     httpd/httpd/trunk/modules/filters/mod_charset_lite.c
>     httpd/httpd/trunk/modules/http/byterange_filter.c
>     httpd/httpd/trunk/modules/http/http_filters.c
>     httpd/httpd/trunk/modules/mappers/mod_actions.c
>     httpd/httpd/trunk/modules/mappers/mod_negotiation.c
>     httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c
>     httpd/httpd/trunk/server/config.c
>     httpd/httpd/trunk/server/core.c
>     httpd/httpd/trunk/server/protocol.c
> 

> Modified: httpd/httpd/trunk/server/config.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=739382&r1=739381&r2=739382&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/config.c (original)
> +++ httpd/httpd/trunk/server/config.c Fri Jan 30 19:12:51 2009
> @@ -355,15 +355,15 @@
>          return result;
>      }
>  
> -    if (!r->handler) {
> -        handler = r->content_type ? r->content_type : ap_default_type(r);
> +    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;
>  
> -            /* MIME type arguments */
> +            /* exclude media type arguments */
>              while (p2 > handler && p2[-1] == ' ')
>                  --p2; /* strip trailing spaces */
>  
> 

This causes the server to crash in case where no r->handler is set (e.g. in the 
case
of a non existing resource).

The following patch fixes this:

Index: server/config.c
===================================================================
--- server/config.c     (Revision 739530)
+++ server/config.c     (Arbeitskopie)
@@ -355,20 +355,25 @@
         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 = "";
+        }

         r->handler = handler;
     }


Comments / thoughts / better ideas? Otherwise I would commit.


Regards

RĂ¼diger


Reply via email to