Skip to content

Commit

Permalink
Open files in binary mode on MingGW
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 6, 2014
1 parent a19ce0b commit aff95c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gnutls.c
Expand Up @@ -265,7 +265,7 @@ static int load_datum(struct openconnect_info *vpninfo,
}
#endif

fd = open(fname, O_RDONLY|O_CLOEXEC);
fd = open(fname, O_RDONLY|O_CLOEXEC|O_BINARY);
if (fd == -1) {
err = errno;
vpn_progress(vpninfo, PRG_ERR,
Expand Down
3 changes: 3 additions & 0 deletions openconnect-internal.h
Expand Up @@ -377,6 +377,9 @@ ssize_t openconnect__win32_sock_write(gnutls_transport_ptr_t ptr, const void *da
#else
#define neterrno() errno
#define closesocket close
#ifndef O_BINARY
#define O_BINARY 0
#endif
#endif

/* I always coded as if it worked like this. Now it does. */
Expand Down
4 changes: 2 additions & 2 deletions openssl.c
Expand Up @@ -661,7 +661,7 @@ static int load_certificate(struct openconnect_info *vpninfo)
FILE *f;
PKCS12 *p12;

f = fopen(vpninfo->cert, "r");
f = fopen(vpninfo->cert, "rb");
if (!f) {
vpn_progress(vpninfo, PRG_ERR,
_("Failed to open certificate file %s: %s\n"),
Expand Down Expand Up @@ -749,7 +749,7 @@ static int load_certificate(struct openconnect_info *vpninfo)
#endif /* ANDROID_KEYSTORE */

if (vpninfo->cert_type == CERT_TYPE_UNKNOWN) {
FILE *f = fopen(vpninfo->sslkey, "r");
FILE *f = fopen(vpninfo->sslkey, "rb");
char buf[256];

if (!f) {
Expand Down

0 comments on commit aff95c7

Please sign in to comment.