curl/libcurl-ocloexec.patch
Tomáš Chvátal cd408e41f8 Accepting request 781412 from home:pmonrealgonzalez:branches:devel:libraries:c_c++
- Update to 7.69.0
  * Changes:
    - polarssl: removed
    - smtp: add CURLOPT_MAIL_RCPT_ALLLOWFAILS and --mail-rcpt-allowfails
    - wolfSSH: new SSH backend 
  * Bugfixes:
    - altsvc: improved header parser
    - altsvc: keep a copy of the file name to survive handle reset
    - altsvc: make saving the cache an atomic operation
    - altsvc: use h3-27
    - azure: disable brotli on the macos debug-builds
    - build: remove all HAVE_OPENSSL_ENGINE_H defines
    - cleanup: fix several comment typos
    - cleanup: fix typos and wording in docs and comments
    - cmake: add support for CMAKE_LTO option
    - cmake: clean up and improve build procedures
    - cmake: Show HTTPS-proxy in the features output
    - cmake: use check_symbol_exists also for inet_pton
    - configure.ac: fix comments about --with-quiche
    - configure: disable metalink if mbedTLS is specified
    - configure: disable metalink support for incompatible SSL/TLS
    - conn: do not reuse connection if SOCKS proxy credentials differ
    - conncache: removed unused Curl_conncache_bundle_size()
    - connect: remove some spurious infof() calls
    - connection reuse: respect the max_concurrent_streams limits
    - cookie: check __Secure- and __Host- case sensitively
    - cookies: make saving atomic with a rename
    - create-dirs.d: mention the mode
    - curl: avoid using strlen for testing if a string is empty
    - curl: error on --alt-svc use w/o support

OBS-URL: https://build.opensuse.org/request/show/781412
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/curl?expand=0&rev=270
2020-03-04 10:49:53 +00:00

93 lines
3.2 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.69.0/lib/file.c
===================================================================
--- curl-7.69.0.orig/lib/file.c
+++ curl-7.69.0/lib/file.c
@@ -192,7 +192,7 @@ static CURLcode file_connect(struct conn
return CURLE_URL_MALFORMAT;
}
- fd = open_readonly(real_path, O_RDONLY);
+ fd = open_readonly(real_path, O_RDONLY|O_CLOEXEC);
file->path = real_path;
#endif
file->freepath = real_path; /* free this when done */
@@ -285,7 +285,7 @@ static CURLcode file_upload(struct conne
else
mode = MODE_DEFAULT|O_TRUNC;
- fd = open(file->path, mode, conn->data->set.new_file_perms);
+ fd = open(file->path, mode | O_CLOEXEC, conn->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.69.0/lib/hostip6.c
===================================================================
--- curl-7.69.0.orig/lib/hostip6.c
+++ curl-7.69.0/lib/hostip6.c
@@ -44,7 +44,7 @@
#ifdef HAVE_PROCESS_H
#include <process.h>
#endif
-
+#include <fcntl.h>
#include "urldata.h"
#include "sendf.h"
#include "hostip.h"
@@ -76,7 +76,7 @@ bool Curl_ipv6works(struct connectdata *
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;
Index: curl-7.69.0/lib/if2ip.c
===================================================================
--- curl-7.69.0.orig/lib/if2ip.c
+++ curl-7.69.0/lib/if2ip.c
@@ -201,7 +201,7 @@ if2ip_result_t Curl_if2ip(int af, unsign
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.69.0/lib/connect.c
===================================================================
--- curl-7.69.0.orig/lib/connect.c
+++ curl-7.69.0/lib/connect.c
@@ -1529,7 +1529,7 @@ CURLcode Curl_socket(struct connectdata
}
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.69.0/configure.ac
===================================================================
--- curl-7.69.0.orig/configure.ac
+++ curl-7.69.0/configure.ac
@@ -196,6 +196,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