mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
fix parsing: stricter checks for CRLF
This commit is contained in:
parent
3dd2a480db
commit
d38eb852f8
2 changed files with 6 additions and 0 deletions
|
|
@ -50,7 +50,10 @@ let parse_ ~(buf : Buf.t) (bs : IO.Input.t) : t =
|
|||
let rec loop acc =
|
||||
match IO.Input.read_line_using_opt ~buf bs with
|
||||
| None -> raise End_of_file
|
||||
| Some "" -> assert false
|
||||
| Some "\r" -> acc
|
||||
| Some line when line.[String.length line - 1] <> '\r' ->
|
||||
bad_reqf 400 "bad header line, not ended in CRLF"
|
||||
| Some line ->
|
||||
let k, v =
|
||||
try
|
||||
|
|
|
|||
|
|
@ -110,6 +110,9 @@ let parse_req_start ~client_addr ~get_time_s ~buf (bs : IO.Input.t) :
|
|||
try
|
||||
let line = IO.Input.read_line_using ~buf bs in
|
||||
Log.debug (fun k -> k "parse request line: %S" line);
|
||||
|
||||
if line <> "" && line.[String.length line - 1] <> '\r' then
|
||||
bad_reqf 400 "invalid status line, not ending in CRLF";
|
||||
let start_time = get_time_s () in
|
||||
let meth, path, version =
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue