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
This commit is contained in:
Jay Satiro
2015-06-01 03:20:18 -04:00
parent 9f5dcab83d
commit e8423f9ce1
10 changed files with 32 additions and 16 deletions

View File

@@ -914,7 +914,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
fp = NULL;
}
else
fp = file?fopen(file, "r"):NULL;
fp = file?fopen(file, FOPEN_READTEXT):NULL;
c->newsession = newsession; /* new session? */
@@ -1262,7 +1262,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
use_stdout=TRUE;
}
else {
out = fopen(dumphere, "w");
out = fopen(dumphere, FOPEN_WRITETEXT);
if(!out)
return 1; /* failure */
}