From 089137f0112b0ad7c8ada8f2d5c7a967cfb87387 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 2 Nov 2010 11:45:14 -0400 Subject: [PATCH 1/2] Fix a bug where seting allow_annotations==0 only ignores annotations, but does not block them --- changes/annotations_fix | 8 ++++++++ src/or/routerparse.c | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 changes/annotations_fix diff --git a/changes/annotations_fix b/changes/annotations_fix new file mode 100644 index 0000000000..d3cd7f343e --- /dev/null +++ b/changes/annotations_fix @@ -0,0 +1,8 @@ + o Major bugfixes + - Do even more to reject (and not just ignore) annotations on + router descriptors received anywhere but from the cache. + Previously we would ignore such annotations at first, but cache + them to disk anyway. Bugfix on 0.2.0.8-alpha. Found by piebeer. + + + diff --git a/src/or/routerparse.c b/src/or/routerparse.c index aa1aba423c..da08e46644 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1177,10 +1177,16 @@ router_parse_entry_from_string(const char *s, const char *end, s = cp+1; } - if (allow_annotations && start_of_annotations != s) { - if (tokenize_string(area,start_of_annotations,s,tokens, - routerdesc_token_table,TS_NOCHECK)) { - log_warn(LD_DIR, "Error tokenizing router descriptor (annotations)."); + if (start_of_annotations != s) { /* We have annotations */ + if (allow_annotations) { + if (tokenize_string(area,start_of_annotations,s,tokens, + routerdesc_token_table,TS_NOCHECK)) { + log_warn(LD_DIR, "Error tokenizing router descriptor (annotations)."); + goto err; + } + } else { + log_warn(LD_DIR, "Found unexpected annotations on router descriptor not " + "loaded from disk. Dropping it."); goto err; } } From 2a50dd9359ec9bd113c64aa91cb5c2dd875de7dd Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 2 Nov 2010 11:49:58 -0400 Subject: [PATCH 2/2] Enforce multiplicity rules when parsing annotations. We would never actually enforce multiplicity rules when parsing annotations, since the counts array never got entries added to it for annotations in the token list that got added by earlier calls to tokenize_string. Found by piebeer. --- changes/annotations_fix | 4 +++- src/or/routerparse.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changes/annotations_fix b/changes/annotations_fix index d3cd7f343e..b259a306d2 100644 --- a/changes/annotations_fix +++ b/changes/annotations_fix @@ -4,5 +4,7 @@ Previously we would ignore such annotations at first, but cache them to disk anyway. Bugfix on 0.2.0.8-alpha. Found by piebeer. - + o Minor bugfixes + - Enforce multiplicity rules when parsing annotations. Bugfix on + 0.2.0.8-alpha. Found by piebeer. diff --git a/src/or/routerparse.c b/src/or/routerparse.c index da08e46644..3d8ca14317 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -3181,6 +3181,9 @@ tokenize_string(memarea_t *area, end = start+strlen(start); for (i = 0; i < _NIL; ++i) counts[i] = 0; + + SMARTLIST_FOREACH(out, const directory_token_t *, t, ++counts[t->tp]); + while (*s < end && (!tok || tok->tp != _EOF)) { tok = get_next_token(area, s, end, table); if (tok->tp == _ERR) {