aboutsummaryrefslogtreecommitdiff
path: root/src/feature/dircache
diff options
context:
space:
mode:
authorjuga0 <juga@riseup.net>2018-11-07 12:04:09 +0000
committerteor <teor@torproject.org>2019-03-26 17:40:54 +1000
commitb75e2539f9994dc04ee7662445878e8486eb77b0 (patch)
tree302ddb2621e296241b9770f684ce5cf0a0e37cb2 /src/feature/dircache
parentee09e5d7eacdfde0cd5e1bc4a18c72fd7e47c1a7 (diff)
downloadtor-b75e2539f9994dc04ee7662445878e8486eb77b0.tar.gz
tor-b75e2539f9994dc04ee7662445878e8486eb77b0.zip
bwauth: check if a bw file could be read
Before serving it by HTTP.
Diffstat (limited to 'src/feature/dircache')
-rw-r--r--src/feature/dircache/dircache.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c
index 2aaaf7be11..d9625ee698 100644
--- a/src/feature/dircache/dircache.c
+++ b/src/feature/dircache/dircache.c
@@ -1453,13 +1453,15 @@ handle_get_next_bandwidth(dir_connection_t *conn,
int lifetime = 60;
char *bandwidth = read_file_to_str(options->V3BandwidthsFile,
RFTS_IGNORE_MISSING, NULL);
- size_t len = strlen(bandwidth);
- write_http_response_header(conn, len, NO_METHOD, lifetime);
- connection_buf_add(bandwidth, len, TO_CONN(conn));
- tor_free(bandwidth);
- } else {
- write_short_http_response(conn, 404, "Not found");
+ if (bandwidth != NULL) {
+ site_t len = strlen(bandwidth);
+ write_http_response_header(conn, len, NO_METHOD, lifetime);
+ connection_buf_add(bandwidth, len, TO_CONN(conn));
+ tor_free(bandwidth);
+ return 0;
+ }
}
+ write_short_http_response(conn, 404, "Not found");
return 0;
}