Skip to content

Commit

Permalink
require tls 1.0.2 and use the Tls_lwt.read with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Sep 4, 2024
1 parent 4b39390 commit 8953381
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion albatross.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ depends: [
"fmt" {>= "0.8.7"}
"x509" {>= "1.0.0"}
"tls" {>= "1.0.0"}
"tls-lwt" {>= "1.0.0"}
"tls-lwt" {>= "1.0.2"}
"mirage-crypto" {>= "1.0.0"}
"mirage-crypto-rng" {>= "1.0.0"}
"asn1-combinators" {>= "0.3.0"}
Expand Down
14 changes: 3 additions & 11 deletions tls/vmm_tls_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ let read_tls t =
if l = 0 then
Lwt.return (Ok ())
else
let buf' =
if off = 0 then buf else Bytes.create l
in
(* TODO Tls_lwt.Unix.read should receive an (optional) "off" parameter. *)
Tls_lwt.Unix.read t buf' >>= function
Tls_lwt.Unix.read t ~off buf >>= function
| 0 ->
Logs.debug (fun m -> m "TLS: end of file") ;
Lwt.return (Error `Eof)
| x when x == l ->
if off = 0 then () else Bytes.blit buf' 0 buf off x;
Lwt.return (Ok ())
| x when x < l ->
if off = 0 then () else Bytes.blit buf' 0 buf off x;
r_n buf (off + x) tot
| x when x == l -> Lwt.return (Ok ())
| x when x < l -> r_n buf (off + x) tot
| _ ->
Logs.err (fun m -> m "TLS: read too much, shouldn't happen") ;
Lwt.return (Error `Toomuch)
Expand Down

0 comments on commit 8953381

Please sign in to comment.