-
Notifications
You must be signed in to change notification settings - Fork 1.5k
nread var incorrect (off by 1) when header spans multiple packets #426
Comments
Confirmed, thanks. Fix in #427. |
correct me if I'm wrong: is |
In http_parser itself? Yes. I know there are some downstream users that use it for whatever reason. It's not part of the public API but that never stopped C programmers before. |
nread can also be used (uofficially) to track the size of the headers, |
I asked @indutny to review it. If he's okay with it, I can merge it and do a 2.8.2 release. |
I've also noticed that the nread is sometimes incorrect when starting to parse a new message (off by 2). |
That'd be best. There may be some backwards compatibility issues to discuss and that's best done in its own issue. |
Fixes: nodejs#426 PR-URL: nodejs#427 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Fixes: nodejs#426 PR-URL: nodejs#427 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Found in version 2.8.1.
If a HTTP header spans 2 IP packets the nread state var is off by one.
The bug is caused since the nread var is incremented before a pointer check is done (which decrements the pointer value by 1):
http_parser.c:1637
should have been:
The same issue seems to reside in http_parser:1342
The issue is easily reproduced by injecting part of an HTTP request and verifying the nread var after http_parser_execute: "GET / HTTP/1.1\r\nHost: myhost".
The text was updated successfully, but these errors were encountered: