[tor-commits] [torsocks/master] Fix: check fileno returned value

dgoulet at torproject.org dgoulet at torproject.org
Fri Apr 4 22:40:26 UTC 2014


commit 729ca3f504b16f6e67d587cb8616daf7efc61f66
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Tue Oct 8 19:24:18 2013 -0400

    Fix: check fileno returned value
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/common/log.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/common/log.c b/src/common/log.c
index 472dc49..2b6e542 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -163,9 +163,10 @@ int log_init(int level, const char *filepath, enum log_time_status t_status)
 		}
 	} else {
 		/* The default output is stderr if no filepath is given. */
-		(void) fileno(stderr);
-		if (errno != EBADF) {
+		ret = fileno(stderr);
+		if (ret < 0 && errno != EBADF) {
 			logconfig.fp = stderr;
+			ret = 0;
 		}
 	}
 





More information about the tor-commits mailing list