2011-11-30 22:43:55 +00: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.
|
|
|
|
|
|
|
|
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: lib/file.c
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- lib/file.c.orig
|
|
|
|
+++ lib/file.c
|
2015-04-22 08:44:51 +00:00
|
|
|
@@ -238,7 +238,7 @@ static CURLcode file_connect(struct conn
|
2014-11-15 16:38:21 +00:00
|
|
|
/* binary zeroes indicate foul play */
|
|
|
|
return CURLE_URL_MALFORMAT;
|
|
|
|
|
2011-11-30 22:43:55 +00: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 */
|
2015-06-19 13:41:49 +00:00
|
|
|
@@ -334,7 +334,7 @@ static CURLcode file_upload(struct conne
|
2012-11-21 13:55:02 +00:00
|
|
|
else
|
|
|
|
mode = MODE_DEFAULT|O_TRUNC;
|
2011-11-30 22:43:55 +00:00
|
|
|
|
2012-11-21 13:55:02 +00:00
|
|
|
- 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;
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: lib/formdata.c
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- lib/formdata.c.orig
|
|
|
|
+++ lib/formdata.c
|
2015-04-22 08:44:51 +00:00
|
|
|
@@ -1256,7 +1256,7 @@ CURLcode Curl_getformdata(struct Session
|
2011-11-30 22:43:55 +00:00
|
|
|
FILE *fileread;
|
|
|
|
|
|
|
|
fileread = strequal("-", file->contents)?
|
|
|
|
- stdin:fopen(file->contents, "rb"); /* binary read for win32 */
|
|
|
|
+ stdin:fopen(file->contents, "rbe"); /* binary read for win32 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VMS: This only allows for stream files on VMS. Stream files are
|
2015-04-22 08:44:51 +00:00
|
|
|
@@ -1415,7 +1415,7 @@ static size_t readfromfile(struct Form *
|
2011-11-30 22:43:55 +00:00
|
|
|
else {
|
|
|
|
if(!form->fp) {
|
|
|
|
/* this file hasn't yet been opened */
|
2013-08-12 05:49:49 +00:00
|
|
|
- form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
|
|
|
|
+ form->fp = fopen_read(form->data->line, "rbe"); /* b is for binary */
|
2011-11-30 22:43:55 +00:00
|
|
|
if(!form->fp)
|
|
|
|
return (size_t)-1; /* failure */
|
|
|
|
}
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: lib/hostip6.c
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- lib/hostip6.c.orig
|
|
|
|
+++ lib/hostip6.c
|
2013-04-13 15:46:54 +00:00
|
|
|
@@ -39,7 +39,7 @@
|
2011-11-30 22:43:55 +00:00
|
|
|
#ifdef HAVE_PROCESS_H
|
|
|
|
#include <process.h>
|
|
|
|
#endif
|
|
|
|
-
|
|
|
|
+#include <fcntl.h>
|
|
|
|
#include "urldata.h"
|
|
|
|
#include "sendf.h"
|
|
|
|
#include "hostip.h"
|
2015-04-22 08:44:51 +00:00
|
|
|
@@ -104,7 +104,7 @@ bool Curl_ipv6works(void)
|
2011-11-30 22:43:55 +00:00
|
|
|
static int ipv6_works = -1;
|
|
|
|
if(-1 == ipv6_works) {
|
|
|
|
/* probe to see if we have a working IPv6 stack */
|
|
|
|
- curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
2012-11-21 13:55:02 +00:00
|
|
|
+ curl_socket_t s = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
2011-11-30 22:43:55 +00:00
|
|
|
if(s == CURL_SOCKET_BAD)
|
2015-01-08 14:54:57 +00:00
|
|
|
/* an IPv6 address was requested but we can't get/use one */
|
2011-11-30 22:43:55 +00:00
|
|
|
ipv6_works = 0;
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: lib/if2ip.c
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- lib/if2ip.c.orig
|
|
|
|
+++ lib/if2ip.c
|
2015-04-22 08:44:51 +00:00
|
|
|
@@ -222,7 +222,7 @@ if2ip_result_t Curl_if2ip(int af, unsign
|
2011-11-30 22:43:55 +00:00
|
|
|
if(len >= sizeof(req.ifr_name))
|
2013-04-13 15:46:54 +00:00
|
|
|
return IF2IP_NOT_FOUND;
|
2011-11-30 22:43:55 +00: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 15:46:54 +00:00
|
|
|
return IF2IP_NOT_FOUND;
|
2011-11-30 22:43:55 +00:00
|
|
|
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: lib/connect.c
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- lib/connect.c.orig
|
|
|
|
+++ lib/connect.c
|
|
|
|
@@ -1337,7 +1337,7 @@ CURLcode Curl_socket(struct connectdata
|
2012-07-30 07:42:51 +00:00
|
|
|
(struct curl_sockaddr *)addr);
|
|
|
|
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 */
|
2014-02-05 08:50:22 +00:00
|
|
|
Index: configure.ac
|
|
|
|
===================================================================
|
2015-06-19 13:41:49 +00:00
|
|
|
--- configure.ac.orig
|
|
|
|
+++ configure.ac
|
2015-01-08 14:54:57 +00:00
|
|
|
@@ -182,6 +182,7 @@ AC_CANONICAL_HOST
|
2012-07-30 07:42:51 +00:00
|
|
|
dnl Get system canonical name
|
|
|
|
AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
|
|
|
|
|
|
|
|
+AC_USE_SYSTEM_EXTENSIONS
|
|
|
|
dnl Checks for programs.
|
|
|
|
|
2013-04-13 15:46:54 +00:00
|
|
|
dnl Our curl_off_t internal and external configure settings
|
2015-01-08 14:54:57 +00:00
|
|
|
@@ -194,6 +195,7 @@ dnl Our configure and build reentrant se
|
2012-07-30 07:42:51 +00:00
|
|
|
CURL_CONFIGURE_THREAD_SAFE
|
|
|
|
CURL_CONFIGURE_REENTRANT
|
|
|
|
|
|
|
|
+
|
|
|
|
dnl check for how to do large files
|
|
|
|
AC_SYS_LARGEFILE
|
|
|
|
|