curl: apply eventfd free patch (#373692)

authored by

Simon Žlender and committed by
Vladimír Čunát
9d9ddb55 d7bc6105

+39
+33
pkgs/by-name/cu/curlMinimal/fix-eventfd-free.patch
···
··· 1 + From ff5091aa9f73802e894b1cbdf24ab84e103200e2 Mon Sep 17 00:00:00 2001 2 + From: Andy Pan <i@andypan.me> 3 + Date: Thu, 12 Dec 2024 12:48:56 +0000 4 + Subject: [PATCH] async-thread: avoid closing eventfd twice 5 + 6 + When employing eventfd for socketpair, there is only one file 7 + descriptor. Closing that fd twice might result in fd corruption. 8 + Thus, we should avoid closing the eventfd twice, following the 9 + pattern in lib/multi.c. 10 + 11 + Fixes #15725 12 + Closes #15727 13 + Reported-by: Christian Heusel 14 + --- 15 + lib/asyn-thread.c | 2 ++ 16 + 1 file changed, 2 insertions(+) 17 + 18 + diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c 19 + index a58e4b790494..32d496b107cb 100644 20 + --- a/lib/asyn-thread.c 21 + +++ b/lib/asyn-thread.c 22 + @@ -195,9 +195,11 @@ void destroy_thread_sync_data(struct thread_sync_data *tsd) 23 + * close one end of the socket pair (may be done in resolver thread); 24 + * the other end (for reading) is always closed in the parent thread. 25 + */ 26 + +#ifndef USE_EVENTFD 27 + if(tsd->sock_pair[1] != CURL_SOCKET_BAD) { 28 + wakeup_close(tsd->sock_pair[1]); 29 + } 30 + +#endif 31 + #endif 32 + memset(tsd, 0, sizeof(*tsd)); 33 + }
+6
pkgs/by-name/cu/curlMinimal/package.nix
··· 63 hash = "sha256-x8p9tIsJCXQ+rvNCUNoCwZvGHU8dzt1mA/EJQJU2q1Y="; 64 }; 65 66 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion 67 # necessary for FreeBSD code path in configure 68 postPatch = ''
··· 63 hash = "sha256-x8p9tIsJCXQ+rvNCUNoCwZvGHU8dzt1mA/EJQJU2q1Y="; 64 }; 65 66 + # FIXME: avoid rebuilding darwin stdenv for now 67 + patches = lib.optionals (!stdenv.isDarwin) [ 68 + # https://github.com/curl/curl/issues/15725 69 + ./fix-eventfd-free.patch 70 + ]; 71 + 72 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion 73 # necessary for FreeBSD code path in configure 74 postPatch = ''