Loading changes/bug27284 0 → 100644 +5 −0 Original line number Diff line number Diff line o Minor bugfixes (ipv6): - When parsing microdescriptors, we should check the IPv6 exit policy alongside IPv4. Previously, we checked both exit policies for only router info structures, while microdescriptors were IPv4-only. Fixes bug 27284; bugfix on 0.2.3.1-alpha. Patch by Neel Chauhan. src/feature/dirparse/microdesc_parse.c +11 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ find_start_of_next_microdesc(const char *s, const char *eos) #undef NEXT_LINE } static inline int policy_is_reject_star_or_null(struct short_policy_t *policy) { return !policy || short_policy_is_reject_star(policy); } /** Parse as many microdescriptors as are found from the string starting at * <b>s</b> and ending at <b>eos</b>. If allow_annotations is set, read any * annotations we recognize and ignore ones we don't. Loading Loading @@ -250,6 +256,11 @@ microdescs_parse_from_string(const char *s, const char *eos, md->ipv6_exit_policy = parse_short_policy(tok->args[0]); } if (policy_is_reject_star_or_null(md->exit_policy) && policy_is_reject_star_or_null(md->ipv6_exit_policy)) { md->policy_is_reject_star = 1; } smartlist_add(result, md); okay = 1; Loading src/feature/nodelist/microdesc_st.h +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ struct microdesc_t { unsigned int no_save : 1; /** If true, this microdesc has an entry in the microdesc_map */ unsigned int held_in_map : 1; /** True iff the exit policy for this router rejects everything. */ unsigned int policy_is_reject_star : 1; /** Reference count: how many node_ts have a reference to this microdesc? */ unsigned int held_by_nodes; Loading src/feature/nodelist/nodelist.c +1 −2 Original line number Diff line number Diff line Loading @@ -1424,8 +1424,7 @@ node_exit_policy_rejects_all(const node_t *node) if (node->ri) return node->ri->policy_is_reject_star; else if (node->md) return node->md->exit_policy == NULL || short_policy_is_reject_star(node->md->exit_policy); return node->md->policy_is_reject_star; else return 1; } Loading src/test/test_microdesc.c +51 −1 Original line number Diff line number Diff line Loading @@ -648,6 +648,41 @@ static const char MD_PARSE_TEST_DATA[] = "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" "p6 allow 80\n" /* Good 11: Normal, non-exit relay with ipv6 address */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" /* Good 12: Normal, exit relay with ipv6 address */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "p accept 20-23,43,53,79-81,88,110,143,194,220,389,443,464,531,543-544\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" /* Good 13: Normal, exit relay with only ipv6 exit policy */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "p6 accept 20-23,43,53,79-81,88,110,143,194,220,389,443,464,531,543-544\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" ; #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS ENABLE_GCC_WARNING(overlength-strings) Loading @@ -665,7 +700,7 @@ test_md_parse(void *arg) smartlist_t *mds = microdescs_parse_from_string(MD_PARSE_TEST_DATA, NULL, 1, SAVED_NOWHERE, invalid); tt_int_op(smartlist_len(mds), OP_EQ, 11); tt_int_op(smartlist_len(mds), OP_EQ, 14); tt_int_op(smartlist_len(invalid), OP_EQ, 4); test_memeq_hex(smartlist_get(invalid,0), Loading Loading @@ -712,6 +747,21 @@ test_md_parse(void *arg) tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); md = smartlist_get(mds, 11); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 1); md = smartlist_get(mds, 12); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 0); md = smartlist_get(mds, 13); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 0); done: SMARTLIST_FOREACH(mds, microdesc_t *, mdsc, microdesc_free(mdsc)); smartlist_free(mds); Loading Loading
changes/bug27284 0 → 100644 +5 −0 Original line number Diff line number Diff line o Minor bugfixes (ipv6): - When parsing microdescriptors, we should check the IPv6 exit policy alongside IPv4. Previously, we checked both exit policies for only router info structures, while microdescriptors were IPv4-only. Fixes bug 27284; bugfix on 0.2.3.1-alpha. Patch by Neel Chauhan.
src/feature/dirparse/microdesc_parse.c +11 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,12 @@ find_start_of_next_microdesc(const char *s, const char *eos) #undef NEXT_LINE } static inline int policy_is_reject_star_or_null(struct short_policy_t *policy) { return !policy || short_policy_is_reject_star(policy); } /** Parse as many microdescriptors as are found from the string starting at * <b>s</b> and ending at <b>eos</b>. If allow_annotations is set, read any * annotations we recognize and ignore ones we don't. Loading Loading @@ -250,6 +256,11 @@ microdescs_parse_from_string(const char *s, const char *eos, md->ipv6_exit_policy = parse_short_policy(tok->args[0]); } if (policy_is_reject_star_or_null(md->exit_policy) && policy_is_reject_star_or_null(md->ipv6_exit_policy)) { md->policy_is_reject_star = 1; } smartlist_add(result, md); okay = 1; Loading
src/feature/nodelist/microdesc_st.h +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ struct microdesc_t { unsigned int no_save : 1; /** If true, this microdesc has an entry in the microdesc_map */ unsigned int held_in_map : 1; /** True iff the exit policy for this router rejects everything. */ unsigned int policy_is_reject_star : 1; /** Reference count: how many node_ts have a reference to this microdesc? */ unsigned int held_by_nodes; Loading
src/feature/nodelist/nodelist.c +1 −2 Original line number Diff line number Diff line Loading @@ -1424,8 +1424,7 @@ node_exit_policy_rejects_all(const node_t *node) if (node->ri) return node->ri->policy_is_reject_star; else if (node->md) return node->md->exit_policy == NULL || short_policy_is_reject_star(node->md->exit_policy); return node->md->policy_is_reject_star; else return 1; } Loading
src/test/test_microdesc.c +51 −1 Original line number Diff line number Diff line Loading @@ -648,6 +648,41 @@ static const char MD_PARSE_TEST_DATA[] = "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" "p6 allow 80\n" /* Good 11: Normal, non-exit relay with ipv6 address */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" /* Good 12: Normal, exit relay with ipv6 address */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "p accept 20-23,43,53,79-81,88,110,143,194,220,389,443,464,531,543-544\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" /* Good 13: Normal, exit relay with only ipv6 exit policy */ "onion-key\n" "-----BEGIN RSA PUBLIC KEY-----\n" "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n" "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n" "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n" "-----END RSA PUBLIC KEY-----\n" "a [::1:2:3:4]:9090\n" "a 18.0.0.1:9999\n" "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n" "p6 accept 20-23,43,53,79-81,88,110,143,194,220,389,443,464,531,543-544\n" "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" ; #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS ENABLE_GCC_WARNING(overlength-strings) Loading @@ -665,7 +700,7 @@ test_md_parse(void *arg) smartlist_t *mds = microdescs_parse_from_string(MD_PARSE_TEST_DATA, NULL, 1, SAVED_NOWHERE, invalid); tt_int_op(smartlist_len(mds), OP_EQ, 11); tt_int_op(smartlist_len(mds), OP_EQ, 14); tt_int_op(smartlist_len(invalid), OP_EQ, 4); test_memeq_hex(smartlist_get(invalid,0), Loading Loading @@ -712,6 +747,21 @@ test_md_parse(void *arg) tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); md = smartlist_get(mds, 11); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 1); md = smartlist_get(mds, 12); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 0); md = smartlist_get(mds, 13); tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6); tt_int_op(md->ipv6_orport, OP_EQ, 9090); tt_int_op(md->policy_is_reject_star, OP_EQ, 0); done: SMARTLIST_FOREACH(mds, microdesc_t *, mdsc, microdesc_free(mdsc)); smartlist_free(mds); Loading