summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-02-15 10:27:32 -0500
committerDavid Goulet <dgoulet@torproject.org>2017-02-15 10:27:41 -0500
commit3336f26e60b0f24c8e028ed8fb9aea04d19c5c8a (patch)
tree2c9321a8a98f391d1d130b9852f95b8debadc87a /src/or/directory.c
parentd633c4757c1392fbbdeb3bdcc39e9b8e834f8fc9 (diff)
downloadtor-3336f26e60b0f24c8e028ed8fb9aea04d19c5c8a.tar.gz
tor-3336f26e60b0f24c8e028ed8fb9aea04d19c5c8a.zip
hs: Avoid a strlen(NULL) if descriptor is not found in cache
Instead of returning 404 error code, this led to a NULL pointer being used and thus a crash of tor. Fixes #21471 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index c7f2012331..80d3c30c63 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3533,7 +3533,7 @@ handle_get_hs_descriptor_v3(dir_connection_t *conn,
pubkey_str = url + strlen("/tor/hs/3/");
retval = hs_cache_lookup_as_dir(HS_VERSION_THREE,
pubkey_str, &desc_str);
- if (retval < 0) {
+ if (retval <= 0 || desc_str == NULL) {
write_http_status_line(conn, 404, "Not found");
goto done;
}