~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to src/HttpHdrRange.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mahyuddin Susanto
  • Date: 2011-02-15 18:46:13 UTC
  • mfrom: (21.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110215184613-1u3dh5sz4i055flk
Tags: 3.1.10-1ubuntu1
* Merge from debian unstable. (LP: #719283)  Remaining changes:
  - debian/patches/18-fix-ftbfs-binutils-gold.dpatch: Add library linker into
    LIBS instead to LDFLAGS to fixing FTBFS binutils-gold.
* Drop Ubuntu configuration for ufw which landed in Debian and sync it: 
  - debian/squid3.ufw.profile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
    } else
99
99
        /* must have a '-' somewhere in _this_ field */
100
100
        if (!((p = strchr(field, '-')) || (p - field >= flen))) {
101
 
            debugs(64, 2, "ignoring invalid (missing '-') range-spec near: '" << field << "'");
 
101
            debugs(64, 2, "invalid (missing '-') range-spec near: '" << field << "'");
102
102
            return false;
103
103
        } else {
104
104
            if (!httpHeaderParseOffset(field, &offset))
113
113
                if (!httpHeaderParseOffset(p, &last_pos))
114
114
                    return false;
115
115
 
 
116
                // RFC 2616 s14.35.1 MUST: last-byte-pos >= first-byte-pos
 
117
                if (last_pos < offset) {
 
118
                    debugs(64, 2, "invalid (last-byte-pos < first-byte-pos) range-spec near: " << field);
 
119
                    return false;
 
120
                }
 
121
 
116
122
                HttpHdrRangeSpec::HttpRange aSpec (offset, last_pos + 1);
117
123
 
118
124
                length = aSpec.size();
119
125
            }
120
126
        }
121
127
 
122
 
    /* we managed to parse, check if the result makes sence */
123
 
    if (length == 0) {
124
 
        debugs(64, 2, "ignoring invalid (zero length) range-spec near: '" << field << "'");
125
 
        return false;
126
 
    }
127
 
 
128
128
    return true;
129
129
}
130
130
 
248
248
    const char *item;
249
249
    const char *pos = NULL;
250
250
    int ilen;
251
 
    int count = 0;
252
251
    assert(this && range_spec);
253
252
    ++ParsedCount;
254
253
    debugs(64, 8, "parsing range field: '" << range_spec << "'");
264
263
    while (strListGetItem(range_spec, ',', &item, &ilen, &pos)) {
265
264
        HttpHdrRangeSpec *spec = HttpHdrRangeSpec::Create(item, ilen);
266
265
        /*
267
 
         * HTTP/1.1 draft says we must ignore the whole header field if one spec
268
 
         * is invalid. However, RFC 2068 just says that we must ignore that spec.
 
266
         * RFC 2616 section 14.35.1: MUST ignore Range with
 
267
         * at least one syntactically invalid byte-range-specs.
269
268
         */
270
 
 
271
 
        if (spec)
272
 
            specs.push_back(spec);
273
 
 
274
 
        ++count;
 
269
        if (!spec) {
 
270
            while (!specs.empty())
 
271
                delete specs.pop_back();
 
272
            debugs(64, 2, "ignoring invalid range field: '" << range_spec << "'");
 
273
            break;
 
274
        }
 
275
 
 
276
        specs.push_back(spec);
275
277
    }
276
278
 
277
 
    debugs(64, 8, "parsed range range count: " << count << ", kept " <<
278
 
           specs.size());
279
 
    return specs.count != 0;
 
279
    debugs(64, 8, "got range specs: " << specs.size());
 
280
    return !specs.empty();
280
281
}
281
282
 
282
283
HttpHdrRange::~HttpHdrRange()