curl/libcurl-ocloexec.patch
David Anes 2c31e47564 Accepting request 1044030 from home:david.anes:branches:devel:libraries:c_c++
- Update to 7.87.0: 
  * Security fixes:
    - CVE-2022-43551, bsc#1206308: another HSTS bypass via IDN
    - CVE-2022-43552, bsc#1206309: HTTP Proxy deny use-after-free
  * Changes
    - curl: add --url-query
    - CURLOPT_QUICK_EXIT: don't wait for DNS thread on exit
    - lib: add CURL_WRITEFUNC_ERROR to signal write callback error
    - openssl: reduce CA certificate bundle reparsing by caching
    - version: add a feature names array to curl_version_info_data 
  * Bugfixes
    - altsvc: fix rejection of negative port numbers
    - aws_sigv4: consult x-%s-content-sha256 for payload hash
    - aws_sigv4: fix typos in aws_sigv4.c
    - base64: better alloc size
    - base64: encode without using snprintf
    - base64: faster base64 decoding
    - build: assume assert.h is always available
    - build: assume errno.h is always available
    - c-hyper: CONNECT respones are not server responses
    - c-hyper: fix multi-request mechanism
    - CI: Change FreeBSD image from 12.3 to 12.4
    - CI: LGTM.com will be shut down in December 2022
    - ci: Remove zuul fuzzing job as it's superseded by CIFuzz
    - cmake: check for cross-compile, not for toolchain
    - CMake: fix build with `CURL_USE_GSSAPI`
    - cmake: really enable warnings with clang
    - cmake: set the soname on the shared library
    - cmdline-opts/gen.pl: fix the linkifier
    - cmdline-opts/page-footer: remove long option nroff formatting

OBS-URL: https://build.opensuse.org/request/show/1044030
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/curl?expand=0&rev=325
2022-12-21 09:09:08 +00:00

94 lines
3.1 KiB
Diff

Open library file descriptors with O_CLOEXEC
This patch is non-portable, it needs linux 2.6.23 and glibc 2.7
or later, different combinations (old linux, new glibc and vice-versa)
will result in a crash.
To make it portable you have to test O_CLOEXEC support at *runtime*
compile time is not enough.
Index: curl-7.87.0/lib/file.c
===================================================================
--- curl-7.87.0.orig/lib/file.c
+++ curl-7.87.0/lib/file.c
@@ -232,7 +232,7 @@ static CURLcode file_connect(struct Curl
}
}
#else
- fd = open_readonly(real_path, O_RDONLY);
+ fd = open_readonly(real_path, O_RDONLY|O_CLOEXEC);
file->path = real_path;
#endif
#endif
@@ -318,7 +318,7 @@ static CURLcode file_upload(struct Curl_
else
mode = MODE_DEFAULT|O_TRUNC;
- fd = open(file->path, mode, data->set.new_file_perms);
+ fd = open(file->path, mode|O_CLOEXEC, data->set.new_file_perms);
if(fd < 0) {
failf(data, "Can't open %s for writing", file->path);
return CURLE_WRITE_ERROR;
Index: curl-7.87.0/lib/if2ip.c
===================================================================
--- curl-7.87.0.orig/lib/if2ip.c
+++ curl-7.87.0/lib/if2ip.c
@@ -206,7 +206,7 @@ if2ip_result_t Curl_if2ip(int af,
if(len >= sizeof(req.ifr_name))
return IF2IP_NOT_FOUND;
- dummy = socket(AF_INET, SOCK_STREAM, 0);
+ dummy = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
if(CURL_SOCKET_BAD == dummy)
return IF2IP_NOT_FOUND;
Index: curl-7.87.0/lib/connect.c
===================================================================
--- curl-7.87.0.orig/lib/connect.c
+++ curl-7.87.0/lib/connect.c
@@ -1559,7 +1559,9 @@ CURLcode Curl_socket(struct Curl_easy *d
}
else
/* opensocket callback not set, so simply create the socket now */
- *sockfd = socket(addr->family, addr->socktype, addr->protocol);
+ *sockfd = socket(addr->family,
+ addr->socktype|SOCK_CLOEXEC,
+ addr->protocol);
if(*sockfd == CURL_SOCKET_BAD)
/* no socket, no connection */
Index: curl-7.87.0/configure.ac
===================================================================
--- curl-7.87.0.orig/configure.ac
+++ curl-7.87.0/configure.ac
@@ -347,6 +347,8 @@ AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-m
# Silence warning: ar: 'u' modifier ignored since 'D' is the default
AC_SUBST(AR_FLAGS, [cr])
+AC_USE_SYSTEM_EXTENSIONS
+
dnl This defines _ALL_SOURCE for AIX
CURL_CHECK_AIX_ALL_SOURCE
Index: curl-7.87.0/lib/hostip.c
===================================================================
--- curl-7.87.0.orig/lib/hostip.c
+++ curl-7.87.0/lib/hostip.c
@@ -48,6 +48,7 @@
#include <signal.h>
#endif
+#include <fcntl.h>
#include "urldata.h"
#include "sendf.h"
#include "hostip.h"
@@ -576,7 +577,7 @@ bool Curl_ipv6works(struct Curl_easy *da
else {
int ipv6_works = -1;
/* probe to see if we have a working IPv6 stack */
- curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
+ curl_socket_t s = socket(PF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if(s == CURL_SOCKET_BAD)
/* an IPv6 address was requested but we can't get/use one */
ipv6_works = 0;