#10 Correct the selection of alloc and free functions for zlib.
Merged 12 days ago by tpokorra. Opened a month ago by johnnyoe.
rpms/ johnnyoe/mono rawhide  into  rawhide

@@ -0,0 +1,35 @@ 

+ From ed68c250b8589663601aa7dd88177697d0b37ec9 Mon Sep 17 00:00:00 2001

+ From: jo-oe <38652639+jo-oe@users.noreply.github.com>

+ Date: Tue, 9 Apr 2024 16:57:39 +0200

+ Subject: [PATCH] Correct the selection of alloc/free functions for zlib.

+ 

+ Avoids segfault when working with zlib-ng.

+ See:

+ https://github.com/zlib-ng/zlib-ng/issues/1708

+ ---

+  support/zlib-helper.c | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/support/zlib-helper.c b/support/zlib-helper.c

+ index 76d8951ad8a8a..a5fbc0138822d 100644

+ --- a/support/zlib-helper.c

+ +++ b/support/zlib-helper.c

+ @@ -76,6 +76,8 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle)

+  		return NULL;

+  

+  	z = z_new0 (z_stream);

+ +	z->zalloc = z_alloc;

+ +	z->zfree = z_free;

+  	if (compress) {

+  		retval = deflateInit2 (z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, gzip ? 31 : -15, 8, Z_DEFAULT_STRATEGY);

+  	} else {

+ @@ -86,8 +88,6 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle)

+  		free (z);

+  		return NULL;

+  	}

+ -	z->zalloc = z_alloc;

+ -	z->zfree = z_free;

+  	result = z_new0 (ZStream);

+  	result->stream = z;

+  	result->func = func;

+ 

file modified
+6 -1
@@ -24,7 +24,7 @@ 

  %global xamarinrelease 199

  Name:           mono

  Version:        6.12.0

- Release:        16%{?dist}

+ Release:        17%{?dist}

  Summary:        Cross-platform, Open Source, .NET development framework

  

  License:        MIT
@@ -59,6 +59,7 @@ 

  # fix issue with conflicts between i686 and x86_64 package (#1853724)

  Patch13:	mono-6.6.0-fix-multi-arch-issue.patch

  Patch14:        mono-configure-c99.patch

+ Patch15:        mono-6.12.0-correct-alloc-free-for-zlib.patch

  

  BuildRequires: make

  BuildRequires:  bison
@@ -351,6 +352,7 @@ 

  %patch -P 12 -p1

  %patch -P 13 -p1

  %patch -P 14 -p1

+ %patch -P 15 -p1

  

  # don't build mono-helix-client which requires the helix-binaries to build

  sed -i 's|mono-helix-client||g' mcs/tools/Makefile
@@ -943,6 +945,9 @@ 

  %files complete

  

  %changelog

+ * Fri Apr 12 2024 Jonas Özbay <jo.spam@gmx.net> - 6.12.0-17

+ - Correct the selection of alloc/free functions for zlib. (as in PR #21759 upstream)

+ 

  * Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 6.12.0-16

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

  

Upstream PR: https://github.com/mono/mono/pull/21759
This will fix a crash when using zlib-ng, as zlib would somehow not expose the problem. (see also: https://github.com/zlib-ng/zlib-ng/issues/1708)

Hi mono package maintainers,

I'm one of the co-maintainers for package zlib-ng at Fedora.
I have reviewed the patch proposed here and I agree with the solution.

This also matches what the zlib manual requests [1]:

The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application.

I'd appreciate if you could review and merge this patch into Rawhide and Fedora 40.
This would prevent errors with mono applications on Fedora >= 40 after we transitioned to zlib-ng [2].

[1] https://www.zlib.net/manual.html#Usage
[2] https://fedoraproject.org/wiki/Changes/ZlibNGTransition

For the record, I believe this PR fixes this new bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2277208

Pull-Request has been merged by tpokorra

12 days ago