You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Uri Shachar <us...@hotmail.com> on 2010/11/14 16:31:22 UTC

mime_parser_parse can look beyond the end of buffer

Hi All,

      When calling mime_parser_parse you are expected to set 'end' to point to one byte beyond the end of the buffer (See docs for INKMimeHdrParse and comment above HTTP.cc:http_parser_parse_req).

If the header buffer ends with a single \r\n AND the 'eof' flag is false, mime_scanner_get will test the byte beyond the end of the buffer to see if it equals a whitespace (This is done to see if this is a multi line header). 
If it is, it will decide the last header in the buffer has a continuation line and (since it has already exceeded the length of the buffer), ignore that header for now (expecting to be called again once more data has arrived).

This can also cause problems for a plugin which calls the parser with a buffer that isn't terminated with \r\n\r\n but with a \r\n -- I'd expect to always get INK_PARSE_CONT (Assuming the headers are formatted ok), with all headers in the buffer being available. 
The parsed data will sometimes not contain the last header in the buffer.

      Cheers,
              Uri Shachar