Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect processing of header's value #13

Open
DmitriyMaksimov opened this issue Sep 11, 2013 · 1 comment
Open

Incorrect processing of header's value #13

DmitriyMaksimov opened this issue Sep 11, 2013 · 1 comment

Comments

@DmitriyMaksimov
Copy link

If we feed multipart parser 1 byte in a time (call multipart_parser_execute() with len == 1) following code:

  case s_header_value:
    multipart_log("s_header_value");
    if (c == CR) {
      EMIT_DATA_CB(header_value, buf + mark, i - mark);
      p->state = s_header_value_almost_done;
    }
    if (is_last)
        EMIT_DATA_CB(header_value, buf + mark, (i - mark) + 1);
    break;

call on_header_value callback twice: first time with len == 0 (which is feature - indicates end of value) and second time with len == 1 and buffer[0] == CR which is bug.
Looks like we missing else statement:

    multipart_log("s_header_value");
    if (c == CR) {
      EMIT_DATA_CB(header_value, buf + mark, i - mark);
      p->state = s_header_value_almost_done;
    } else if (is_last)
        EMIT_DATA_CB(header_value, buf + mark, (i - mark) + 1);

or break:

    multipart_log("s_header_value");
    if (c == CR) {
      EMIT_DATA_CB(header_value, buf + mark, i - mark);
      p->state = s_header_value_almost_done;
      break;
    }
    if (is_last)
        EMIT_DATA_CB(header_value, buf + mark, (i - mark) + 1);
@vincentbernat
Copy link

This bug seems to be fixed in #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants