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.
|
|
|
|
|
|
|
|
|
2023-02-15 22:29:29 +01:00
|
|
|
Index: curl-7.88.0/lib/file.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2023-02-15 22:29:29 +01:00
|
|
|
--- curl-7.88.0.orig/lib/file.c
|
|
|
|
+++ curl-7.88.0/lib/file.c
|
2022-12-21 10:09:08 +01:00
|
|
|
@@ -232,7 +232,7 @@ static CURLcode file_connect(struct Curl
|
2022-08-31 13:55:07 +02:00
|
|
|
}
|
2016-07-21 20:40:30 +02:00
|
|
|
}
|
2022-08-31 13:55:07 +02:00
|
|
|
#else
|
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;
|
2022-08-31 13:55:07 +02:00
|
|
|
#endif
|
2011-11-30 23:43:55 +01:00
|
|
|
#endif
|
2022-12-21 10:09:08 +01:00
|
|
|
@@ -318,7 +318,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);
|
2021-09-15 10:46:22 +02:00
|
|
|
+ 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;
|
2023-02-15 22:29:29 +01:00
|
|
|
Index: curl-7.88.0/lib/if2ip.c
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2023-02-15 22:29:29 +01:00
|
|
|
--- curl-7.88.0.orig/lib/if2ip.c
|
|
|
|
+++ curl-7.88.0/lib/if2ip.c
|
2022-08-31 13:55:07 +02:00
|
|
|
@@ -206,7 +206,7 @@ if2ip_result_t Curl_if2ip(int af,
|
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);
|
2021-09-15 10:46:22 +02:00
|
|
|
+ dummy = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
2011-11-30 23:43:55 +01:00
|
|
|
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
|
|
|
|
2023-02-15 22:29:29 +01:00
|
|
|
Index: curl-7.88.0/configure.ac
|
2014-02-05 09:50:22 +01:00
|
|
|
===================================================================
|
2023-02-15 22:29:29 +01:00
|
|
|
--- curl-7.88.0.orig/configure.ac
|
|
|
|
+++ curl-7.88.0/configure.ac
|
|
|
|
@@ -420,6 +420,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
|
|
|
|
|
2023-02-15 22:29:29 +01:00
|
|
|
Index: curl-7.88.0/lib/hostip.c
|
2021-09-15 10:46:22 +02:00
|
|
|
===================================================================
|
2023-02-15 22:29:29 +01:00
|
|
|
--- curl-7.88.0.orig/lib/hostip.c
|
|
|
|
+++ curl-7.88.0/lib/hostip.c
|
2022-12-21 10:09:08 +01:00
|
|
|
@@ -48,6 +48,7 @@
|
|
|
|
#include <signal.h>
|
2021-09-15 10:46:22 +02:00
|
|
|
#endif
|
2022-12-21 10:09:08 +01:00
|
|
|
|
2021-09-15 10:46:22 +02:00
|
|
|
+#include <fcntl.h>
|
|
|
|
#include "urldata.h"
|
|
|
|
#include "sendf.h"
|
|
|
|
#include "hostip.h"
|
2022-12-21 10:09:08 +01:00
|
|
|
@@ -576,7 +577,7 @@ bool Curl_ipv6works(struct Curl_easy *da
|
2021-09-15 10:46:22 +02:00
|
|
|
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;
|
2023-02-15 22:29:29 +01:00
|
|
|
Index: curl-7.88.0/lib/cf-socket.c
|
|
|
|
===================================================================
|
|
|
|
--- curl-7.88.0.orig/lib/cf-socket.c
|
|
|
|
+++ curl-7.88.0/lib/cf-socket.c
|
|
|
|
@@ -252,7 +252,9 @@ static CURLcode socket_open(struct Curl_
|
|
|
|
}
|
|
|
|
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 && addr->socktype == SOCK_DGRAM) {
|
|
|
|
/* This is icky and seems, at least, to happen on macOS:
|
|
|
|
* we get sockfd == 0 and if called again, we get a valid one > 0.
|