From ba83c1e5cf0e4ba0d63cb3728da059a9b241a161 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 6 Jun 2019 09:12:14 +1000 Subject: [PATCH 1/2] dirparse: Stop crashing when parsing unknown descriptor purpose annotations We think this bug can only be triggered by modifying a local file. Fixes bug 30781; bugfix on 0.2.0.8-alpha. --- changes/bug30781 | 4 ++++ src/or/routerparse.c | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 changes/bug30781 diff --git a/changes/bug30781 b/changes/bug30781 new file mode 100644 index 0000000000..7c7adf470e --- /dev/null +++ b/changes/bug30781 @@ -0,0 +1,4 @@ + o Minor bugfixes (directory authorities): + - Stop crashing after parsing an unknown descriptor purpose annotation. + We think this bug can only be triggered by modifying a local file. + Fixes bug 30781; bugfix on 0.2.0.8-alpha. diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 37d2d975fc..f046cc39b4 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1921,6 +1921,9 @@ router_parse_entry_from_string(const char *s, const char *end, if ((tok = find_opt_by_keyword(tokens, A_PURPOSE))) { tor_assert(tok->n_args); router->purpose = router_purpose_from_string(tok->args[0]); + if (router->purpose == ROUTER_PURPOSE_UNKNOWN) { + goto err; + } } else { router->purpose = ROUTER_PURPOSE_GENERAL; } From b07b1a4f6d1aae3755db7ccfa9e7417214375f13 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 6 Jun 2019 13:42:30 +1000 Subject: [PATCH 2/2] practracker: accept 3 extra lines in router_parse_entry_from_string() practracker exception for bug 30781. --- scripts/maint/practracker/exceptions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt index eb0625b8d3..db9bf34e25 100644 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@ -189,7 +189,7 @@ problem function-size /src/feature/dirparse/ns_parse.c:networkstatus_verify_bw_w problem function-size /src/feature/dirparse/ns_parse.c:networkstatus_parse_vote_from_string() 638 problem function-size /src/feature/dirparse/parsecommon.c:tokenize_string() 103 problem function-size /src/feature/dirparse/parsecommon.c:get_next_token() 159 -problem function-size /src/feature/dirparse/routerparse.c:router_parse_entry_from_string() 554 +problem function-size /src/feature/dirparse/routerparse.c:router_parse_entry_from_string() 557 problem function-size /src/feature/dirparse/routerparse.c:extrainfo_parse_entry_from_string() 210 problem function-size /src/feature/hibernate/hibernate.c:accounting_parse_options() 109 problem function-size /src/feature/hs/hs_cell.c:hs_cell_build_establish_intro() 115