Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6844 closed defect (fixed)

Make read_file_to_string() work on cygwin

Reported by: nickm Owned by:
Priority: Medium Milestone: Tor: 0.2.3.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-client
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

On IRC, a user reports that we fail to load the state file at startup on cygwin. That's apparently because the _WIN32-only code in read_file_to_string() needs to be enabled for cygwin too.

Trivial, tested patch:

diff --git a/src/common/util.c b/src/common/util.c
index d4d7cb3..5329a05 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2328,7 +2328,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.",

Child Tickets

Change History (6)

comment:1 Changed 7 years ago by nickm

Status: newneeds_review

I'm marking this as needs_review (rather than just merging it) mainly because I want to merge it into 0.2.3.x: fixing an entire platform with a single-line commit seems like a worthwhile 0.2.3.x item.

comment:2 in reply to:  1 Changed 7 years ago by rransom

Replying to nickm:

I'm marking this as needs_review (rather than just merging it) mainly because I want to merge it into 0.2.3.x: fixing an entire platform with a single-line commit seems like a worthwhile 0.2.3.x item.

If 0.2.3.x currently does not work when built for Cygwin, then there is no reason to not merge this change there -- no other platform has any business defining __CYGWIN__.

comment:3 Changed 7 years ago by arma

0.2.3 sounds good to me

(with a changes file)

comment:4 Changed 7 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Fixed in b1447a4312c47f13bf8ddddab09f19ee73640a3e

(with a changes file)

comment:5 Changed 7 years ago by nickm

Keywords: tor-client added

comment:6 Changed 7 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.