Fix rare SIGSEGV when transferring large replicas.

from Alex Markley via Davide Gerhard
This commit is contained in:
giovanni 2017-03-06 16:04:22 +00:00
parent 9f6425be2e
commit 6503680461
2 changed files with 46 additions and 1 deletions

View File

@ -1,9 +1,10 @@
# $OpenBSD: Makefile,v 1.10 2016/06/27 13:34:49 giovanni Exp $ # $OpenBSD: Makefile,v 1.11 2017/03/06 16:04:22 giovanni Exp $
COMMENT= multi-platform file synchronization tool COMMENT= multi-platform file synchronization tool
CATEGORIES= net CATEGORIES= net
V= 2.48.4 V= 2.48.4
REVISION= 0
DISTNAME= unison-${V} DISTNAME= unison-${V}
MASTER_SITES= ${HOMEPAGE}download/releases/stable/ MASTER_SITES= ${HOMEPAGE}download/releases/stable/

View File

@ -0,0 +1,44 @@
$OpenBSD: patch-patch-bytearray_stubs_c,v 1.1 2017/03/06 16:04:22 giovanni Exp $
--- patch-bytearray_stubs_c.orig Fri Jan 20 23:42:43 2017
+++ patch-bytearray_stubs_c Fri Jan 20 23:42:56 2017
@@ -0,0 +1,40 @@
+
+Fix rare SIGSEGV when transferring large replicas.
+Fix a theoretical integer overflow.
+
+References:
+https://github.com/bcpierce00/unison/commit/c1ddff13aa96b124680cce61673129aeb563dbf7
+https://github.com/bcpierce00/unison/commit/f59663d67f4593a5bc1e554058fe6864751e805e
+
+Thanks to Alex Markley and OCaml developers
+--- bytearray_stubs.c.orig Tue Jan 17 08:41:00 2017
++++ bytearray_stubs.c Tue Jan 17 08:41:21 2017
+@@ -5,6 +5,7 @@
+ #include "caml/intext.h"
+
+ #include "caml/bigarray.h"
++#include "caml/memory.h"
+
+ CAMLprim value ml_marshal_to_bigarray(value v, value flags)
+ {
+@@ -21,15 +22,18 @@ CAMLprim value ml_marshal_to_bigarray(value v, value f
+
+ CAMLprim value ml_unmarshal_from_bigarray(value b, value ofs)
+ {
++ CAMLparam1(b); /* Holds [b] live until unmarshalling completes. */
++ value result;
+ struct caml_bigarray *b_arr = Bigarray_val(b);
+- return input_value_from_block (Array_data (b_arr, ofs),
++ result = input_value_from_block (Array_data (b_arr, ofs),
+ b_arr->dim[0] - Long_val(ofs));
++ CAMLreturn(result);
+ }
+
+ CAMLprim value ml_blit_string_to_bigarray
+ (value s, value i, value a, value j, value l)
+ {
+- char *src = String_val(s) + Int_val(i);
++ char *src = String_val(s) + Long_val(i);
+ char *dest = Array_data(Bigarray_val(a), j);
+ memcpy(dest, src, Long_val(l));
+ return Val_unit;