2011-11-30 23:43:55 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
|
2021-02-04 15:43:03 +01:00
|
|
|
Index: curl-7.75.0/lib/file.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2021-02-04 15:43:03 +01:00
|
|
|
--- curl-7.75.0.orig/lib/file.c
|
|
|
|
+++ curl-7.75.0/lib/file.c
|
|
|
|
@@ -193,7 +193,7 @@ static CURLcode file_connect(struct Curl
|
2014-11-15 17:38:21 +01:00
|
|
|
return CURLE_URL_MALFORMAT;
|
2016-07-21 20:40:30 +02:00
|
|
|
}
|
2014-11-15 17:38:21 +01:00
|
|
|
|
2011-11-30 23:43:55 +01:00
|
|
|
- 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 */
|
2021-02-04 15:43:03 +01:00
|
|
|
@@ -277,7 +277,7 @@ static CURLcode file_upload(struct Curl_
|
2012-11-21 14:55:02 +01:00
|
|
|
else
|
|
|
|
mode = MODE_DEFAULT|O_TRUNC;
|
2011-11-30 23:43:55 +01:00
|
|
|
|
2021-02-04 15:43:03 +01:00
|
|
|
- fd = open(file->path, mode, data->set.new_file_perms);
|
|
|
|
+ fd = open(file->path, mode | O_CLOEXEC, data->set.new_file_perms);
|
2012-11-21 14:55:02 +01:00
|
|
|
if(fd < 0) {
|
|
|
|
failf(data, "Can't open %s for writing", file->path);
|
|
|
|
return CURLE_WRITE_ERROR;
|
2021-02-04 15:43:03 +01:00
|
|
|
Index: curl-7.75.0/lib/hostip6.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2021-02-04 15:43:03 +01:00
|
|
|
--- curl-7.75.0.orig/lib/hostip6.c
|
|
|
|
+++ curl-7.75.0/lib/hostip6.c
|
2018-03-14 17:35:07 +01:00
|
|
|
@@ -44,7 +44,7 @@
|
2011-11-30 23:43:55 +01:00
|
|
|
#ifdef HAVE_PROCESS_H
|
|
|
|
#include <process.h>
|
|
|
|
#endif
|
|
|
|
-
|
|
|
|
+#include <fcntl.h>
|
|
|
|
#include "urldata.h"
|
|
|
|
#include "sendf.h"
|
|
|
|
#include "hostip.h"
|
2021-02-04 15:43:03 +01:00
|
|
|
@@ -75,7 +75,7 @@ bool Curl_ipv6works(struct Curl_easy *da
|
2020-03-04 11:49:53 +01:00
|
|
|
else {
|
|
|
|
int ipv6_works = -1;
|
2011-11-30 23:43:55 +01:00
|
|
|
/* probe to see if we have a working IPv6 stack */
|
|
|
|
- curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
2012-11-21 14:55:02 +01:00
|
|
|
+ curl_socket_t s = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
2011-11-30 23:43:55 +01:00
|
|
|
if(s == CURL_SOCKET_BAD)
|
2015-01-08 15:54:57 +01:00
|
|
|
/* an IPv6 address was requested but we can't get/use one */
|
2011-11-30 23:43:55 +01:00
|
|
|
ipv6_works = 0;
|
2021-02-04 15:43:03 +01:00
|
|
|
Index: curl-7.75.0/lib/if2ip.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2021-02-04 15:43:03 +01:00
|
|
|
--- curl-7.75.0.orig/lib/if2ip.c
|
|
|
|
+++ curl-7.75.0/lib/if2ip.c
|
|
|
|
@@ -202,7 +202,7 @@ if2ip_result_t Curl_if2ip(int af, unsign
|
2011-11-30 23:43:55 +01:00
|
|
|
if(len >= sizeof(req.ifr_name))
|
2013-04-13 17:46:54 +02:00
|
|
|
return IF2IP_NOT_FOUND;
|
2011-11-30 23:43:55 +01:00
|
|
|
|
|
|
|
- dummy = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
+ dummy = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
|
|
|
if(CURL_SOCKET_BAD == dummy)
|
2013-04-13 17:46:54 +02:00
|
|
|
return IF2IP_NOT_FOUND;
|
2011-11-30 23:43:55 +01:00
|
|
|
|
2021-02-04 15:43:03 +01:00
|
|
|
Index: curl-7.75.0/lib/connect.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2021-02-04 15:43:03 +01:00
|
|
|
--- curl-7.75.0.orig/lib/connect.c
|
|
|
|
+++ curl-7.75.0/lib/connect.c
|
|
|
|
@@ -1575,7 +1575,9 @@ CURLcode Curl_socket(struct Curl_easy *d
|
2018-03-14 17:35:07 +01:00
|
|
|
}
|
2012-07-30 09:42:51 +02:00
|
|
|
else
|
|
|
|
/* opensocket callback not set, so simply create the socket now */
|
|
|
|
- *sockfd = socket(addr->family, addr->socktype, addr->protocol);
|
2020-12-19 19:24:38 +01:00
|
|
|
+ *sockfd = socket(addr->family,
|
|
|
|
+ addr->socktype | SOCK_CLOEXEC,
|
|
|
|
+ addr->protocol);
|
2012-07-30 09:42:51 +02:00
|
|
|
|
|
|
|
if(*sockfd == CURL_SOCKET_BAD)
|
|
|
|
/* no socket, no connection */
|
2021-02-04 15:43:03 +01:00
|
|
|
Index: curl-7.75.0/configure.ac
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2021-02-04 15:43:03 +01:00
|
|
|
--- curl-7.75.0.orig/configure.ac
|
|
|
|
+++ curl-7.75.0/configure.ac
|
|
|
|
@@ -189,6 +189,8 @@ AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-m
|
2018-07-17 16:51:01 +02:00
|
|
|
# Silence warning: ar: 'u' modifier ignored since 'D' is the default
|
|
|
|
AC_SUBST(AR_FLAGS, [cr])
|
2012-07-30 09:42:51 +02:00
|
|
|
|
|
|
|
+AC_USE_SYSTEM_EXTENSIONS
|
2018-07-17 16:51:01 +02:00
|
|
|
+
|
2017-10-10 12:18:27 +02:00
|
|
|
dnl This defines _ALL_SOURCE for AIX
|
2018-07-17 16:51:01 +02:00
|
|
|
CURL_CHECK_AIX_ALL_SOURCE
|
|
|
|
|