httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/http mod_mime.c
Date Sat, 04 Aug 2001 04:32:59 GMT
wrowe       01/08/03 21:32:59

  Modified:    modules/mappers mod_negotiation.c
               modules/http mod_mime.c
  Log:
    Subtle variation for security.  If the mod_mime file has nothing specific
    to say about a given set of file extentions (and has only based the
    resolved fields on the default language, encoding and content type)
    then tell us we can ignore the result by leaving the exception list
    entirely undefined.  If mod_mime adds anything (a language, charset, or
    whatnot) then proceed to use the file in the Multiviews evaluation,
    otherwise mod_negotation will ignore the file found.
  
    This points out a need for a slightly twisted DefaultClientLanguage,
    as opposed to creating foo.html.html files.  Either that, or introduce
    a 'neutral' entity that the user can list (say, .default) for mod_mime
    to declare it as a fallback language/encoding/content-type/handler.
  
  Revision  Changes    Path
  1.64      +39 -22    httpd-2.0/modules/mappers/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_negotiation.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- mod_negotiation.c	2001/08/03 22:57:47	1.63
  +++ mod_negotiation.c	2001/08/04 04:32:58	1.64
  @@ -962,36 +962,54 @@
               sub_req->content_type = CGI_MAGIC_TYPE;
           }
   
  +        /* 
  +         * mod_mime will _always_ provide us the base name in the
  +         * ap-mime-exception-list, if it processed anything.  If
  +         * this list is empty, give up immediately, there was
  +         * nothing interesting.  For example, looking at the files
  +         * readme.txt and readme.foo, we will throw away .foo if
  +         * it's an insignificant file (e.g. did not identify a 
  +         * language, charset, encoding, content type or handler,)
  +         */
           exception_list = 
               (apr_array_header_t *)apr_table_get(sub_req->notes, 
                                                   "ap-mime-exceptions-list");
  -        if (exception_list) {
  -            /* Every last missing bit danged well better be in our table!
  -             * Simple enough for now, every unregonized bit better match
  -             * our base name.  When we break up our base name and allow
  -             * index.en to match index.html.en, this gets tricker.
  -             */
  -            char *base = apr_array_pstrcat(sub_req->pool, exception_list, '.');
  -            int base_len = strlen(base);
  -            if (base_len > prefix_len 
  +
  +        if (!exception_list) {
  +            ap_destroy_sub_req(sub_req);
  +            continue;
  +        }
  +
  +        /*
  +         * Simple enough for now, every unregonized bit better match
  +         * our base name.  When we break up our base name and allow
  +         * index.en to match index.html.en, this gets tricker.
  +         * XXX: index.html.foo won't be caught by testing index.html
  +         * since the exceptions result is index.foo - this should be
  +         * fixed as part of a new match-parts logic here.
  +         */
  +        char *base = apr_array_pstrcat(sub_req->pool, exception_list, '.');
  +        int base_len = strlen(base);
  +        if (base_len > prefix_len 
   #ifdef CASE_BLIND_FILESYSTEM
  -                || strncasecmp(base, filp, base_len)
  +            || strncasecmp(base, filp, base_len)
   #else
  -                || strncmp(base, filp, base_len)
  +            || strncmp(base, filp, base_len)
   #endif
  -                || (prefix_len > base_len && filp[base_len] != '.')) {
  -                /* 
  -                 * Something you don't know is, something you don't know...
  -                 */
  -                ap_destroy_sub_req(sub_req);
  -                continue;
  -            }
  +            || (prefix_len > base_len && filp[base_len] != '.')) {
  +            /* 
  +             * Something you don't know is, something you don't know...
  +             */
  +            ap_destroy_sub_req(sub_req);
  +            continue;
           }
   
  -        /* XXX If we successfully negotate ANYTHING, continue
  +        /* 
  +         * ###: be warned, the _default_ content type is already
  +         * picked up here!  If we failed the subrequest, or don't 
  +         * know what we are serving, then continue.
            */
  -        if (sub_req->status != HTTP_OK ||
  -            (!sub_req->content_type && !exception_list)) {
  +        if (sub_req->status != HTTP_OK || (!sub_req->content_type) {
               ap_destroy_sub_req(sub_req);
               continue;
           }
  @@ -999,7 +1017,6 @@
           /* If it's a map file, we use that instead of the map
            * we're building...
            */
  -
           if (((sub_req->content_type) &&
                !strcmp(sub_req->content_type, MAP_FILE_MAGIC_TYPE)) ||
               ((sub_req->handler) &&
  
  
  
  1.49      +7 -3      httpd-2.0/modules/http/mod_mime.c
  
  Index: mod_mime.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- mod_mime.c	2001/08/04 01:29:38	1.48
  +++ mod_mime.c	2001/08/04 04:32:59	1.49
  @@ -787,6 +787,7 @@
       char *ext;
       const char *type;
       const char *charset = NULL;
  +    int found_any = 0;
       apr_array_header_t *exception_list =
           apr_array_make(r->pool, 2, sizeof(char *));
   
  @@ -869,15 +870,18 @@
   
           /* Not good... nobody claims it.
            */
  -        if (!found)
  +        if (found)
  +            found_any = 1;
  +        else
               *((const char **) apr_array_push(exception_list)) = ext;
       }
   
       /*
        * Need to set a notes entry on r for unrecognized elements.
  -     * Somebody better claim them!
  +     * Somebody better claim them!  If we did absolutely nothing,
  +     * skip the notes to alert mod_negotiation we are clueless.
        */
  -    if (exception_list->nelts) {
  +    if (found_any) {
           apr_table_setn(r->notes, "ap-mime-exceptions-list", 
                          (void *)exception_list);
       }
  
  
  

Mime
View raw message