[tor-commits] [tor/master] bwauth: check if a bw file could be read
teor at torproject.org
teor at torproject.org
Tue Mar 26 09:16:26 UTC 2019
commit b75e2539f9994dc04ee7662445878e8486eb77b0
Author: juga0 <juga at riseup.net>
Date: Wed Nov 7 12:04:09 2018 +0000
bwauth: check if a bw file could be read
Before serving it by HTTP.
---
src/feature/dircache/dircache.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c
index 2aaaf7be1..d9625ee69 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;
}
More information about the tor-commits
mailing list