summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-02-27 15:42:57 +0100
committerAlexander Færøy <ahf@torproject.org>2017-03-01 21:26:27 +0100
commit3dca5a6e71929f88c9c76f6ebbaac58789884b6e (patch)
tree98494b44b88ba4eecbe3a919fb9d288da4c17de1 /src/or
parent498287b3c340739bede9a3fa95ea23b6ae650bf3 (diff)
downloadtor-3dca5a6e71929f88c9c76f6ebbaac58789884b6e.tar.gz
tor-3dca5a6e71929f88c9c76f6ebbaac58789884b6e.zip
Use tor_fgets() instead of fgets().
This patch changes our use of fgets() to tor_fgets() for more consistent error handling across different versions of the C library.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dirserv.c4
-rw-r--r--src/or/geoip.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index f01668adcb..2c3ce100df 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2701,7 +2701,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
return -1;
}
- if (!fgets(line, sizeof(line), fp)
+ if (!tor_fgets(line, sizeof(line), fp)
|| !strlen(line) || line[strlen(line)-1] != '\n') {
log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
escaped(line));
@@ -2731,7 +2731,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
while (!feof(fp)) {
measured_bw_line_t parsed_line;
- if (fgets(line, sizeof(line), fp) && strlen(line)) {
+ if (tor_fgets(line, sizeof(line), fp) && strlen(line)) {
if (measured_bw_line_parse(&parsed_line, line) != -1) {
/* Also cache the line for dirserv_get_bandwidth_for_router() */
dirserv_cache_measured_bw(&parsed_line, file_time);
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 74811ea643..a8dc807c19 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -346,7 +346,7 @@ geoip_load_file(sa_family_t family, const char *filename)
(family == AF_INET) ? "IPv4" : "IPv6", filename);
while (!feof(f)) {
char buf[512];
- if (fgets(buf, (int)sizeof(buf), f) == NULL)
+ if (tor_fgets(buf, (int)sizeof(buf), f) == NULL)
break;
crypto_digest_add_bytes(geoip_digest_env, buf, strlen(buf));
/* FFFF track full country name. */