summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-09-14 12:37:17 -0400
committerNick Mathewson <nickm@torproject.org>2012-09-14 12:39:18 -0400
commitb1447a4312c47f13bf8ddddab09f19ee73640a3e (patch)
tree1a1a13ad683ba910e16d297f69973164345e8c95
parent909691f1ae9e2b8cd806cdf43b43f99b97c5c0f4 (diff)
downloadtor-b1447a4312c47f13bf8ddddab09f19ee73640a3e.tar.gz
tor-b1447a4312c47f13bf8ddddab09f19ee73640a3e.zip
Use file-size-fixup code on cygwin too.
We already had code on windows to fix our file sizes when we're reading a file in text mode and its size doesn't match the size from fstat. But that code was only enabled when _WIN32 was defined, and Cygwin defines __CYGWIN__ instead. Fixes bug 6844; bugfix on 0.1.2.7-alpha.
-rw-r--r--changes/bug68444
-rw-r--r--src/common/util.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/changes/bug6844 b/changes/bug6844
new file mode 100644
index 0000000000..338e19d9a5
--- /dev/null
+++ b/changes/bug6844
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Correct file sizes when reading binary files on
+ Cygwin, to avoid a bug where Tor would fail to read its state file.
+ Fixes bug 6844; bugfix on 0.1.2.7-alpha.
diff --git a/src/common/util.c b/src/common/util.c
index 55f4d906f5..6fb597a3a5 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2322,7 +2322,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
}
string[r] = '\0'; /* NUL-terminate the result. */
-#ifdef _WIN32
+#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.",