Skip to content

Commit d4f260e

Browse files
David Scottjohnelse
authored andcommitted
CA-73047: fix a file descriptor leak in is_cmdline_valid
Signed-off-by: David Scott <[email protected]>
1 parent 98bcf98 commit d4f260e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ocaml/xenops/device.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,9 @@ let pid ~xs domid =
833833
(* Look up the commandline args for the vncterm pid; *)
834834
(* Check that they include the vncterm binary path and the xenstore console path for the supplied domid. *)
835835
let is_cmdline_valid domid pid =
836-
let cmdline_path = Printf.sprintf "/proc/%d/cmdline" pid in
837-
let cmdline = Unix.openfile cmdline_path [Unix.O_RDONLY] 0
838-
|> Unixext.try_read_string
836+
let cmdline =
837+
Printf.sprintf "/proc/%d/cmdline" pid
838+
|> Unixext.string_of_file
839839
|> String.split '\000'
840840
in
841841
if (List.mem vncterm_path cmdline) && (List.mem (vnc_console_path domid) cmdline)

0 commit comments

Comments
 (0)