upstream: github.com/mirleft/ocaml-tls
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(tls): guard parse_change_cipher_spec against empty input

Tuple evaluation caused get_uint8 to be called before the length
check, crashing on empty buffers. Use short-circuit && instead.

+2 -3
+2 -3
lib/reader.ml
··· 92 92 | _ -> raise_unknown @@ "alert level " ^ string_of_int level 93 93 94 94 let parse_change_cipher_spec buf = 95 - match (String.length buf, String.get_uint8 buf 0) with 96 - | 1, 1 -> Ok () 97 - | _ -> Error (`Decode "bad change cipher spec message") 95 + if String.length buf = 1 && String.get_uint8 buf 0 = 1 then Ok () 96 + else Error (`Decode "bad change cipher spec message") 98 97 99 98 let rec parse_count_list parsef buf acc = function 100 99 | 0 -> (List.rev acc, buf)