diff --git a/ocaml-pgocaml.spec b/ocaml-pgocaml.spec index 4d33f4d..da547c0 100644 --- a/ocaml-pgocaml.spec +++ b/ocaml-pgocaml.spec @@ -15,6 +15,9 @@ URL: http://pgocaml.forge.ocamlcore.org/ # (see comment above) we can go back to a website link here. Source0: pgocaml-%{version}.tgz +# Safe-string fixes for OCaml 4.06. +Patch1: pgocaml-1.6-safe-string.patch + BuildRequires: ocaml >= 3.10.0 BuildRequires: ocaml-findlib-devel, ocaml-ocamldoc BuildRequires: ocaml-extlib-devel @@ -46,6 +49,7 @@ developing applications that use %{name}. %prep %setup -q -n pgocaml-%{version} +%autopatch -p1 %build @@ -99,8 +103,9 @@ install -m 0755 pgocaml_prof $RPM_BUILD_ROOT%{_bindir} %changelog -* Sat Nov 18 2017 Richard W.M. Jones - 1.6-28 +* Wed Nov 22 2017 Richard W.M. Jones - 1.6-28 - OCaml 4.06.0 rebuild. +- Safe string fixes. * Wed Aug 09 2017 Richard W.M. Jones - 1.6-27 - Bump release and rebuild. diff --git a/pgocaml-1.6-safe-string.patch b/pgocaml-1.6-safe-string.patch new file mode 100644 index 0000000..9b2bffe --- /dev/null +++ b/pgocaml-1.6-safe-string.patch @@ -0,0 +1,187 @@ +Binary files pgocaml-1.6.old/pGOCaml.cmi and pgocaml-1.6/pGOCaml.cmi differ +Binary files pgocaml-1.6.old/pGOCaml_generic.cmi and pgocaml-1.6/pGOCaml_generic.cmi differ +diff -ur pgocaml-1.6.old/pGOCaml_generic.ml pgocaml-1.6/pGOCaml_generic.ml +--- pgocaml-1.6.old/pGOCaml_generic.ml 2012-04-13 13:55:09.000000000 +0100 ++++ pgocaml-1.6/pGOCaml_generic.ml 2017-11-22 15:52:09.933379044 +0000 +@@ -48,7 +48,7 @@ + val flush : out_channel -> unit t + val input_char : in_channel -> char t + val input_binary_int : in_channel -> int t +- val really_input : in_channel -> string -> int -> int -> unit t ++ val really_input : in_channel -> bytes -> int -> int -> unit t + val close_in : in_channel -> unit t + end + +@@ -434,7 +434,7 @@ + if len > !max_message_length then ( + (* Skip the message so we stay in synch with the stream. *) + let bufsize = 65_536 in +- let buf = String.create bufsize in ++ let buf = Bytes.create bufsize in + let rec loop n = + if n > 0 then begin + let m = min n bufsize in +@@ -450,7 +450,7 @@ + ) else ( + + (* Read the binary message content. *) +- let msg = String.create len in ++ let msg = Bytes.create len in + really_input ichan msg 0 len >>= fun () -> + return (typ, msg) + ) +@@ -627,17 +627,17 @@ + | 2l -> AuthenticationKerberosV5 + | 3l -> AuthenticationCleartextPassword + | 4l -> +- let salt = String.create 2 in ++ let salt = Bytes.create 2 in + for i = 0 to 2 do +- salt.[i] <- get_char () ++ Bytes.set salt i (get_char ()) + done; +- AuthenticationCryptPassword salt ++ AuthenticationCryptPassword (Bytes.to_string salt) + | 5l -> +- let salt = String.create 4 in ++ let salt = Bytes.create 4 in + for i = 0 to 3 do +- salt.[i] <- get_char () ++ Bytes.set salt i (get_char ()) + done; +- AuthenticationMD5Password salt ++ AuthenticationMD5Password (Bytes.to_string salt) + | 6l -> AuthenticationSCMCredential + | _ -> UnknownMessage (typ, msg) + ); +@@ -704,7 +704,7 @@ + if len > Sys.max_string_length then + raise (Error "PGOCaml: result field is too wide for string"); + let bytes = get_n_bytes len in +- len, bytes ++ len, Bytes.to_string bytes + ) in + fields := field :: !fields + done; +@@ -794,8 +794,8 @@ + | None -> return () + | Some conn -> + let rec loop () = +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with ReadyForQuery _ -> return () | _ -> loop () + in + loop () +@@ -968,8 +968,8 @@ + let rec loop msg = + (match msg with + | Some msg -> send_recv conn msg +- | None -> receive_message conn) >>= fun msg -> +- let msg = parse_backend_message msg in ++ | None -> receive_message conn) >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + + match msg with + | ReadyForQuery _ -> return () (* Finished connecting! *) +@@ -1051,8 +1051,8 @@ + + (* Wait for ReadyForQuery. *) + let rec loop () = +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ReadyForQuery _ -> return () (* Finished! *) + | ErrorResponse err -> pg_error ~conn err (* Error *) +@@ -1086,8 +1086,8 @@ + send_message conn msg >>= fun () -> + flush_msg conn >>= fun () -> + let rec loop () = +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ErrorResponse err -> pg_error err + | ParseComplete -> return () (* Finished! *) +@@ -1137,8 +1137,8 @@ + *) + let rec loop () = + (* NB: receive_message flushes the output connection. *) +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ReadyForQuery _ -> return () (* Finished! *) + | ErrorResponse err -> pg_error ~conn err (* Error *) +@@ -1253,8 +1253,8 @@ + send_message conn msg >>= fun () -> + flush_msg conn >>= fun () -> + let rec loop () = +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ErrorResponse err -> pg_error err + | CloseComplete -> return () (* Finished! *) +@@ -1274,8 +1274,8 @@ + send_message conn msg >>= fun () -> + flush_msg conn >>= fun () -> + let rec loop () = +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ErrorResponse err -> pg_error err + | CloseComplete -> return () +@@ -1309,8 +1309,8 @@ + add_string msg name; + send_message conn msg >>= fun () -> + flush_msg conn >>= fun () -> +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + ( match msg with + | ErrorResponse err -> pg_error err + | ParameterDescription params -> +@@ -1322,8 +1322,8 @@ + | _ -> + fail (Error ("PGOCaml: unknown response from describe: " ^ + string_of_msg_t msg))) >>= fun params -> +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ErrorResponse err -> pg_error err + | NoData -> return (params, None) +@@ -1350,8 +1350,8 @@ + add_string msg portal; + send_message conn msg >>= fun () -> + flush_msg conn >>= fun () -> +- receive_message conn >>= fun msg -> +- let msg = parse_backend_message msg in ++ receive_message conn >>= fun (c, msg) -> ++ let msg = parse_backend_message (c, Bytes.to_string msg) in + match msg with + | ErrorResponse err -> pg_error err + | NoData -> return None +diff -ur pgocaml-1.6.old/pGOCaml_generic.mli pgocaml-1.6/pGOCaml_generic.mli +--- pgocaml-1.6.old/pGOCaml_generic.mli 2012-04-13 13:55:09.000000000 +0100 ++++ pgocaml-1.6/pGOCaml_generic.mli 2017-11-22 15:52:26.785377248 +0000 +@@ -38,7 +38,7 @@ + val flush : out_channel -> unit t + val input_char : in_channel -> char t + val input_binary_int : in_channel -> int t +- val really_input : in_channel -> string -> int -> int -> unit t ++ val really_input : in_channel -> bytes -> int -> int -> unit t + val close_in : in_channel -> unit t + end +