aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fs
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-14 14:50:30 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-14 14:50:30 -0400
commita7226ca06e20356abb057c29416a9ad969c8d29d (patch)
tree7c16645bccb3245ccbe03eaf465995d4cfedb625 /src/lib/fs
parentaba0ff4cb587e8771f360b516e2029aa6efcd547 (diff)
parent623af0155e0664f46adb1fcc218bc193a9d15916 (diff)
downloadtor-a7226ca06e20356abb057c29416a9ad969c8d29d.tar.gz
tor-a7226ca06e20356abb057c29416a9ad969c8d29d.zip
Merge remote-tracking branch 'tor-gitlab/mr/50'
Diffstat (limited to 'src/lib/fs')
-rw-r--r--src/lib/fs/files.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/fs/files.c b/src/lib/fs/files.c
index aeaeb5daea..a0b5a40aac 100644
--- a/src/lib/fs/files.c
+++ b/src/lib/fs/files.c
@@ -607,6 +607,9 @@ read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out)
* If <b>flags</b> &amp; RFTS_BIN, open the file in binary mode.
* If <b>flags</b> &amp; RFTS_IGNORE_MISSING, don't warn if the file
* doesn't exist.
+ *
+ * Unless the RFTS_BIN flag is set in <b>flags</b>, this function will strip
+ * any CR characters in the return value on all platforms.
*/
/*
* This function <em>may</em> return an erroneous result if the file
@@ -685,7 +688,6 @@ read_file_to_str, (const char *filename, int flags, struct stat *stat_out))
}
string[r] = '\0'; /* NUL-terminate the result. */
-#if defined(_WIN32) || defined(__CYGWIN__)
if (!bin && strchr(string, '\r')) {
log_debug(LD_FS, "We didn't convert CRLF to LF as well as we hoped "
"when reading %s. Coping.",
@@ -695,8 +697,7 @@ read_file_to_str, (const char *filename, int flags, struct stat *stat_out))
}
if (!bin) {
statbuf.st_size = (size_t) r;
- } else
-#endif /* defined(_WIN32) || defined(__CYGWIN__) */
+ } else {
if (r != statbuf.st_size) {
/* Unless we're using text mode on win32, we'd better have an exact
* match for size. */
@@ -708,6 +709,7 @@ read_file_to_str, (const char *filename, int flags, struct stat *stat_out))
errno = save_errno;
return NULL;
}
+ }
close(fd);
if (stat_out) {
memcpy(stat_out, &statbuf, sizeof(struct stat));