Permalink
Browse files

Merge pull request #943 from jeromemaloberti/CA-92154-lcm

CA-92154: Handle metrics files larger than 16 KiB
  • Loading branch information...
2 parents b2f03c4 + 1285502 commit 82759a023eca81e39eb7c34a40ef4f76ebe25b9f @johnelse johnelse committed Mar 1, 2013
Showing with 9 additions and 6 deletions.
  1. +9 −6 ocaml/rrdd/rrdd_server.ml
View
15 ocaml/rrdd/rrdd_server.ml
@@ -463,13 +463,16 @@ module Plugin = struct
Hashtbl.add open_files path fd;
fd
- (* A function that reads using Unix.read a string of specified length from
- * the specified file. *)
+ (* A function that reads using Unixext.really_read a string of specified
+ * length from the specified file. *)
let read_string ~(fd : Unix.file_descr) ~(length : int) : string =
- let buffer = String.create length in
- let read = Unix.read fd buffer 0 length in
- if read <> length then raise Read_error;
- buffer
+ try
+ (* CA-92154: use Unixext.really_read since Unix.read will
+ * not read a string longer than 16384 bytes *)
+ Unixext.really_read_string fd length
+ with _ ->
+ log_backtrace ();
+ raise Read_error
(* The payload type that corresponds to the plugin output file format. *)
type payload = {

0 comments on commit 82759a0

Please sign in to comment.