curl/libcurl-ocloexec.patch
Michal Vyskocil 1ba1e0ce69 Accepting request 280328 from home:vitezslav_cizek:branches:devel:libraries:c_c++
- update to 7.40.0:
  * fixes CVE-2014-8150 (bnc#911363)
  * Changes:
    http_digest: Added support for Windows SSPI based authentication
    version info: Added Kerberos V5 to the supported features
    Makefile: Added VC targets for WinIDN
    config-win32: Introduce build targets for VS2012+
    SSL: Add PEM format support for public key pinning
    smtp: Added support for the conversion of Unix newlines during mail send
    smb: Added initial support for the SMB/CIFS protocol
    Added support for HTTP over unix domain sockets,
    via CURLOPT_UNIX_SOCKET_PATH and --unix-socket
    sasl: Added support for GSS-API based Kerberos V5 authentication

OBS-URL: https://build.opensuse.org/request/show/280328
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/curl?expand=0&rev=121
2015-01-08 14:54:57 +00:00

157 lines
5.6 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: lib/cookie.c
===================================================================
--- lib/cookie.c.orig 2014-12-10 00:01:02.000000000 +0100
+++ lib/cookie.c 2015-01-08 11:33:25.855588512 +0100
@@ -932,7 +932,7 @@ struct CookieInfo *Curl_cookie_init(stru
fp = NULL;
}
else
- fp = file?fopen(file, "r"):NULL;
+ fp = file?fopen(file, "re"):NULL;
c->newsession = newsession; /* new session? */
@@ -1281,7 +1281,7 @@ static int cookie_output(struct CookieIn
use_stdout=TRUE;
}
else {
- out = fopen(dumphere, "w");
+ out = fopen(dumphere, "we");
if(!out)
return 1; /* failure */
}
Index: lib/file.c
===================================================================
--- lib/file.c.orig 2014-11-20 18:42:17.000000000 +0100
+++ lib/file.c 2015-01-08 11:33:25.855588512 +0100
@@ -240,7 +240,7 @@ static CURLcode file_connect(struct conn
/* binary zeroes indicate foul play */
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 */
@@ -338,7 +338,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: lib/formdata.c
===================================================================
--- lib/formdata.c.orig 2014-11-20 18:42:17.000000000 +0100
+++ lib/formdata.c 2015-01-08 11:33:25.856588523 +0100
@@ -1261,7 +1261,7 @@ CURLcode Curl_getformdata(struct Session
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
@@ -1420,7 +1420,7 @@ static size_t readfromfile(struct Form *
else {
if(!form->fp) {
/* this file hasn't yet been opened */
- form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
+ form->fp = fopen_read(form->data->line, "rbe"); /* b is for binary */
if(!form->fp)
return (size_t)-1; /* failure */
}
Index: lib/hostip6.c
===================================================================
--- lib/hostip6.c.orig 2014-12-28 14:36:05.000000000 +0100
+++ lib/hostip6.c 2015-01-08 11:33:25.856588523 +0100
@@ -39,7 +39,7 @@
#ifdef HAVE_PROCESS_H
#include <process.h>
#endif
-
+#include <fcntl.h>
#include "urldata.h"
#include "sendf.h"
#include "hostip.h"
@@ -107,7 +107,7 @@ bool Curl_ipv6works(void)
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);
+ 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: lib/if2ip.c
===================================================================
--- lib/if2ip.c.orig 2014-12-28 14:36:05.000000000 +0100
+++ lib/if2ip.c 2015-01-08 11:33:25.856588523 +0100
@@ -224,7 +224,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: lib/netrc.c
===================================================================
--- lib/netrc.c.orig 2014-11-04 13:51:16.000000000 +0100
+++ lib/netrc.c 2015-01-08 11:33:25.856588523 +0100
@@ -111,7 +111,7 @@ int Curl_parsenetrc(const char *host,
netrc_alloc = TRUE;
}
- file = fopen(netrcfile, "r");
+ file = fopen(netrcfile, "re");
if(netrc_alloc)
Curl_safefree(netrcfile);
if(file) {
Index: lib/connect.c
===================================================================
--- lib/connect.c.orig 2014-12-28 14:36:05.000000000 +0100
+++ lib/connect.c 2015-01-08 11:33:25.856588523 +0100
@@ -1314,7 +1314,7 @@ CURLcode Curl_socket(struct connectdata
(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 */
Index: configure.ac
===================================================================
--- configure.ac.orig 2014-12-28 14:36:05.000000000 +0100
+++ configure.ac 2015-01-08 11:33:55.103922543 +0100
@@ -182,6 +182,7 @@ AC_CANONICAL_HOST
dnl Get system canonical name
AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
+AC_USE_SYSTEM_EXTENSIONS
dnl Checks for programs.
dnl Our curl_off_t internal and external configure settings
@@ -194,6 +195,7 @@ dnl Our configure and build reentrant se
CURL_CONFIGURE_THREAD_SAFE
CURL_CONFIGURE_REENTRANT
+
dnl check for how to do large files
AC_SYS_LARGEFILE