~ubuntu-branches/ubuntu/vivid/tomcat6/vivid-proposed

« back to all changes in this revision

Viewing changes to java/org/apache/coyote/http11/filters/ChunkedInputFilter.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-02-17 00:02:00 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20140217000200-qs6ki7bhqnfhkas7
Tags: 6.0.39-1
* Team upload.
* New upstream release.
  - Refreshed the patches
* Standards-Version updated to 3.9.5 (no changes)
* Switch to debhelper level 9
* Use XZ compression for the upstream tarball
* Use canonical URL for the Vcs-Git field

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
 
116
116
    /**
 
117
     * Size of extensions processed for this request.
 
118
     */
 
119
    private long extensionSize;
 
120
    
 
121
    
 
122
    /**
117
123
     * Flag set to true if the next call to doRead() must parse a CRLF pair
118
124
     * before doing anything else.
119
125
     */
248
254
        endChunk = false;
249
255
        needCRLFParse = false;
250
256
        trailingHeaders.recycle();
 
257
        if (org.apache.coyote.Constants.MAX_TRAILER_SIZE > 0) {
 
258
            trailingHeaders.setLimit(org.apache.coyote.Constants.MAX_TRAILER_SIZE);
 
259
        }
 
260
        extensionSize = 0;
251
261
    }
252
262
 
253
263
 
294
304
        int result = 0;
295
305
        boolean eol = false;
296
306
        boolean readDigit = false;
297
 
        boolean trailer = false;
 
307
        boolean extension = false;
298
308
 
299
309
        while (!eol) {
300
310
 
306
316
            if (buf[pos] == Constants.CR || buf[pos] == Constants.LF) {
307
317
                parseCRLF(false);
308
318
                eol = true;
309
 
            } else if (buf[pos] == Constants.SEMI_COLON) {
310
 
                trailer = true;
311
 
            } else if (!trailer) { 
 
319
            } else if (buf[pos] == Constants.SEMI_COLON && !extension) {
 
320
                // First semi-colon marks the start of the extension. Further
 
321
                // semi-colons may appear to separate multiple chunk-extensions.
 
322
                // These need to be processed as part of parsing the extensions.
 
323
                extension = true;
 
324
                extensionSize++;
 
325
            } else if (!extension) { 
312
326
                //don't read data after the trailer
313
327
                int charValue = HexUtils.getDec(buf[pos]);
314
328
                if (charValue != -1) {
320
334
                    //in the chunked header
321
335
                    return false;
322
336
                }
 
337
            } else {
 
338
                // Extension 'parsing'
 
339
                // Note that the chunk-extension is neither parsed nor
 
340
                // validated. Currently it is simply ignored.
 
341
                extensionSize++;
 
342
                if (org.apache.coyote.Constants.MAX_EXTENSION_SIZE > -1 &&
 
343
                        extensionSize > org.apache.coyote.Constants.MAX_EXTENSION_SIZE) {
 
344
                    throw new IOException("maxExtensionSize exceeded");
 
345
                }
323
346
            }
324
347
 
325
348
            // Parsing the CRLF increments pos
485
508
                chr = buf[pos];
486
509
                if ((chr == Constants.SP) || (chr == Constants.HT)) {
487
510
                    pos++;
 
511
                    // If we swallow whitespace, make sure it counts towards the
 
512
                    // limit placed on trailing header size (if there is one)
 
513
                    if (trailingHeaders.getLimit() != -1) {
 
514
                        int newlimit = trailingHeaders.getLimit() -1;
 
515
                        if (trailingHeaders.getEnd() > newlimit) {
 
516
                            throw new IOException("Exceeded maxTrailerSize");
 
517
                        }
 
518
                        trailingHeaders.setLimit(newlimit);
 
519
                    }
488
520
                } else {
489
521
                    space = false;
490
522
                }