Skip to content

Commit

Permalink
Do not crash LSP server on malformed Content-Length
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed Apr 11, 2022
1 parent c25d7c9 commit 32502df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/fstar/FStar.Interactive.Lsp.fst
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ let rec parse_header_len (stream: stream_reader) (len: int): int =
match U.read_line stream with
| Some s ->
if U.starts_with s "Content-Length: " then
parse_header_len stream (U.int_of_string (U.substring_from s 16))
match U.safe_int_of_string (U.substring_from s 16) with
| Some new_len -> parse_header_len stream new_len
| None -> raise MalformedHeader
else if U.starts_with s "Content-Type: " then
parse_header_len stream len
else if s = "" then
Expand Down
9 changes: 7 additions & 2 deletions src/ocaml-output/FStar_Interactive_Lsp.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32502df

Please sign in to comment.