Commit b3ec4d38 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Add in MaxRangeOverlaps and MaxRangeReversals to accomodate

more control over acceptable Range headers:

        See: http://trac.tools.ietf.org/wg/httpbis/trac/ticket/311

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1169756 13f79535-47bb-0310-9956-ffa450edef68
parent d823ef6c
Loading
Loading
Loading
Loading
+5 −0
Changes for CHANGES: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,11 @@ Changes with Apache 2.3.15
     PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener,
     <lowprio20 gmail.com>]

  *) core: Add MaxRangeOverlaps and MaxRangeReversals directives to control
     the number of overlapping and reversing ranges (respectively) permitted
     before returning the entire resource, with a default limit of 20.
     [Jim Jagielski]

  *) mod_ldap: Optional function uldap_ssl_supported(r) always returned false
     if called from a virtual host with mod_ldap directives in it.  Did not
     affect mod_authnz_ldap's usage of mod_ldap.  [Eric Covener]
+71 −0
Changes for docs/manual/mod/core.xml: 71 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2865,6 +2865,7 @@ connection</description>
    </example>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>MaxRanges</name>
<description>Number of ranges allowed before returning the complete
@@ -2900,6 +2901,76 @@ resource </description>
</usage>
</directivesynopsis>

<directivesynopsis>
    <name>MaxRangeOverlaps</name>
    <description>Number of overlapping ranges (eg: <code>100-200,150-300</code>) allowed before returning the complete
        resource </description>
    <syntax>MaxRangeOverlaps default | unlimited | none | <var>number-of-ranges</var></syntax>
    <default>MaxRangeOverlaps 20</default>
    <contextlist><context>server config</context><context>virtual host</context>
        <context>directory</context>
    </contextlist>
    <compatibility>Available in Apache HTTP Server 2.3.15 and later</compatibility>

    <usage>
        <p>The <directive>MaxRangeOverlaps</directive> directive
            limits the number of overlapping HTTP ranges the server is willing to
            return to the client.  If more overlapping ranges then permitted are requested,
            the complete resource is returned instead.</p>

        <dl>
            <dt><strong>default</strong></dt>
            <dd>Limits the number of overlapping ranges to a compile-time default of 20.</dd>

            <dt><strong>none</strong></dt>
            <dd>No overlapping Range headers are allowed.</dd>

            <dt><strong>unlimited</strong></dt>
            <dd>The server does not limit the number of overlapping ranges it is
                willing to satisfy.</dd>

            <dt><var>number-of-ranges</var></dt>
            <dd>A positive number representing the maximum number of overlapping ranges the
                server is willing to satisfy.</dd>
        </dl>
    </usage>
</directivesynopsis>

<directivesynopsis>
    <name>MaxRangeReversals</name>
    <description>Number of range reversals (eg: <code>100-200,50-70</code>) allowed before returning the complete
        resource </description>
    <syntax>MaxRangeReversals default | unlimited | none | <var>number-of-ranges</var></syntax>
    <default>MaxRangeReversals 20</default>
    <contextlist><context>server config</context><context>virtual host</context>
        <context>directory</context>
    </contextlist>
    <compatibility>Available in Apache HTTP Server 2.3.15 and later</compatibility>

    <usage>
        <p>The <directive>MaxRangeReversals</directive> directive
            limits the number of HTTP Range reversals the server is willing to
            return to the client.  If more ranges reversals then permitted are requested,
            the complete resource is returned instead.</p>

        <dl>
            <dt><strong>default</strong></dt>
            <dd>Limits the number of range reversals to a compile-time default of 20.</dd>

            <dt><strong>none</strong></dt>
            <dd>No Range reversals headers are allowed.</dd>

            <dt><strong>unlimited</strong></dt>
            <dd>The server does not limit the number of range reversals it is
                willing to satisfy.</dd>

            <dt><var>number-of-ranges</var></dt>
            <dd>A positive number representing the maximum number of range reversals the
                server is willing to satisfy.</dd>
        </dl>
    </usage>
</directivesynopsis>

<directivesynopsis>
<name>Mutex</name>
<description>Configures mutex mechanism and lock file directory for all
+2 −1
Changes for include/ap_mmn.h: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -350,6 +350,7 @@
 * 20110724.3 (2.3.15-dev) add util_varbuf.h / ap_varbuf API
 * 20110724.4 (2.3.15-dev) add max_ranges to core_dir_config
 * 20110724.5 (2.3.15-dev) add ap_set_accept_ranges()
 * 20110724.6 (2.3.15-dev) add max_overlaps and max_reversals to core_dir_config
 */

#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -357,7 +358,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110724
#endif
#define MODULE_MAGIC_NUMBER_MINOR 5                    /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 6                    /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+4 −0
Changes for include/http_core.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -611,6 +611,10 @@ typedef struct {
#define AP_MAXRANGES_NORANGES   0
    /** Number of Ranges before returning HTTP_OK. **/
    int max_ranges;
    /** Max number of Range overlaps (merges) allowed **/
    int max_overlaps;
    /** Max number of Range reversals (eg: 200-300, 100-125) allowed **/
    int max_reversals;

} core_dir_config;

+18 −3
Changes for modules/http/byterange_filter.c: 18 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@
#ifndef AP_DEFAULT_MAX_RANGES
#define AP_DEFAULT_MAX_RANGES 200
#endif
#ifndef AP_DEFAULT_MAX_OVERLAPS
#define AP_DEFAULT_MAX_OVERLAPS 20
#endif
#ifndef AP_DEFAULT_MAX_REVERSALS
#define AP_DEFAULT_MAX_REVERSALS 20
#endif

#define MAX_PREALLOC_RANGES 100

@@ -442,13 +448,19 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
    indexes_t *idx;
    int i;
    int original_status;
    int max_ranges;
    int max_ranges, max_overlaps, max_reversals;
    int overlaps = 0, reversals = 0;
    core_dir_config *core_conf = ap_get_core_module_config(r->per_dir_config);

    max_ranges = ( (core_conf->max_ranges >= 0 || core_conf->max_ranges == AP_MAXRANGES_UNLIMITED)
                   ? core_conf->max_ranges
                   : AP_DEFAULT_MAX_RANGES );
    max_overlaps = ( (core_conf->max_overlaps >= 0 || core_conf->max_overlaps == AP_MAXRANGES_UNLIMITED)
                  ? core_conf->max_overlaps
                  : AP_DEFAULT_MAX_OVERLAPS );
    max_reversals = ( (core_conf->max_reversals >= 0 || core_conf->max_reversals == AP_MAXRANGES_UNLIMITED)
                  ? core_conf->max_reversals
                  : AP_DEFAULT_MAX_REVERSALS );
    /*
     * Iterate through the brigade until reaching EOS or a bucket with
     * unknown length.
@@ -474,8 +486,11 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
    original_status = r->status;
    num_ranges = ap_set_byterange(r, clength, &indexes, &overlaps, &reversals);

    /* We have nothing to do, get out of the way. */
    if (num_ranges == 0 || (max_ranges >= 0 && num_ranges > max_ranges)) {
    /* No Ranges or we hit a limit? We have nothing to do, get out of the way. */
    if (num_ranges == 0 ||
        (max_ranges >= 0 && num_ranges > max_ranges) ||
        (max_overlaps >= 0 && overlaps > max_overlaps) ||
        (max_reversals >= 0 && reversals > max_reversals)) {
        r->status = original_status;
        ap_remove_output_filter(f);
        return ap_pass_brigade(f->next, bb);
Loading