Menu

#38 Bug in request header parsing

open
nobody
Bug (26)
8
2012-11-19
2012-11-19
Anonymous
No

The SegmentConsumer has a bug that causes Simple to close the connection to the client. The bug occurs when the request, including headers, have a length of 1024+n*512.

Discussion

  • Anonymous

    Anonymous - 2012-11-19

    Run the attached unit test to reproduce the bug

     
  • Anonymous

    Anonymous - 2012-11-19

    The bug is fixed by replacing the SegmentConsumer.value() method to:

    private void value() {
    Token token = new Token(pos, 0);

    scan: for(int mark = 0; pos < count;){
    if(terminal(array[pos])) { /* CR or LF */
    for(int i = 0; pos < count; i++){
    if(array[pos++] == 10) { /* skip the LF */
    if(pos < array.length && space(array[pos])) {
    mark += i + 1; /* account for bytes examined */
    break; /* folding line */
    }
    break scan; /* not a folding line */
    }
    }
    } else {
    if(!space(array[pos])){
    token.size = ++mark;
    } else {
    mark++;
    }
    pos++;
    }
    }
    value = token.text();
    }

     
  • Niall Gallagher

    Niall Gallagher - 2012-12-08

    Can u provide more info???

     
  • Anonymous

    Anonymous - 2013-02-28

    The bug causes Simple to close the connection to the client. I have attached a unittest reproducing the issue

     

Log in to post a comment.

Auth0 Logo