aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2015-04-02 12:42:06 +0000
committerNick Mathewson <nickm@torproject.org>2015-04-06 09:21:43 -0400
commitdc3cb0008085d173800724304573dc4ed341c793 (patch)
treee61cdcdec2b6f9c0d69c64a7905897f092bf412b /src/or/routerparse.c
parent7b5f558da4542ecce992a8bdb65851fd4a1713bc (diff)
downloadtor-dc3cb0008085d173800724304573dc4ed341c793.tar.gz
tor-dc3cb0008085d173800724304573dc4ed341c793.zip
Handle empty/zero length encoded intro points more gracefully.
In theory these should never the triggered as the only caller now validates the parameters before this routine gets called.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 01f65f262b..176c16f904 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -4928,7 +4928,7 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed,
size_t intro_points_encoded_size)
{
const char *current_ipo, *end_of_intro_points;
- smartlist_t *tokens;
+ smartlist_t *tokens = NULL;
directory_token_t *tok;
rend_intro_point_t *intro;
extend_info_t *info;
@@ -4937,8 +4937,10 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed,
tor_assert(parsed);
/** Function may only be invoked once. */
tor_assert(!parsed->intro_nodes);
- tor_assert(intro_points_encoded);
- tor_assert(intro_points_encoded_size > 0);
+ if (!intro_points_encoded || intro_points_encoded_size == 0) {
+ log_warn(LD_REND, "Empty or zero size introduction point list");
+ goto err;
+ }
/* Consider one intro point after the other. */
current_ipo = intro_points_encoded;
end_of_intro_points = intro_points_encoded + intro_points_encoded_size;
@@ -5042,8 +5044,10 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed,
done:
/* Free tokens and clear token list. */
- SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
- smartlist_free(tokens);
+ if (tokens) {
+ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
+ smartlist_free(tokens);
+ }
if (area)
memarea_drop_all(area);