From e8423f9ce1507c749c559f1ac1847fa433e66c45 Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Mon, 1 Jun 2015 03:20:18 -0400 Subject: curl_setup: Add macros for FOPEN_READTEXT, FOPEN_WRITETEXT - Change fopen calls to use FOPEN_READTEXT instead of "r" or "rt" - Change fopen calls to use FOPEN_WRITETEXT instead of "w" or "wt" This change is to explicitly specify when we need to read/write text. Unfortunately 't' is not part of POSIX fopen so we can't specify it directly. Instead we now have FOPEN_READTEXT, FOPEN_WRITETEXT. Prior to this change we had an issue on Windows if an application that uses libcurl overrides the default file mode to binary. The default file mode in Windows is normally text mode (translation mode) and that's what libcurl expects. Bug: https://github.com/bagder/curl/pull/258#issuecomment-107093055 Reported-by: Orgad Shaneh --- lib/vtls/gtls.c | 2 +- lib/vtls/openssl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/vtls') diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index d6eb6c445..1db31e40c 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -231,7 +231,7 @@ static gnutls_datum_t load_file (const char *file) long filelen; void *ptr; - if(!(f = fopen(file, "r"))) + if(!(f = fopen(file, "rb"))) return loaded_file; if(fseek(f, 0, SEEK_END) != 0 || (filelen = ftell(f)) < 0 diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 96a7d6e89..eb2cf5bf5 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -2725,7 +2725,7 @@ static CURLcode servercert(struct connectdata *conn, /* e.g. match issuer name with provided issuer certificate */ if(data->set.str[STRING_SSL_ISSUERCERT]) { - fp = fopen(data->set.str[STRING_SSL_ISSUERCERT], "r"); + fp = fopen(data->set.str[STRING_SSL_ISSUERCERT], FOPEN_READTEXT); if(!fp) { if(strict) failf(data, "SSL: Unable to open issuer cert (%s)", -- cgit v1.2.3