[tor-commits] [tor/maint-0.3.4] Merge branch 'maint-0.2.9' into maint-0.3.2

nickm at torproject.org nickm at torproject.org
Wed Jul 18 19:12:41 UTC 2018


commit 559f79fd79b7c22caac2888f82e92307be02904a
Merge: 61a2762e3 a321d7240
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jul 18 15:03:27 2018 -0400

    Merge branch 'maint-0.2.9' into maint-0.3.2

 changes/bug26485    |  4 ++++
 src/or/config.c     |  9 ++++++++-
 src/or/dirserv.c    | 43 +++++++++++++++++++++++++++++++++++++------
 src/or/dirserv.h    |  3 +--
 src/or/dirvote.c    |  9 ++++++++-
 src/test/test_dir.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 6 files changed, 110 insertions(+), 11 deletions(-)

diff --cc src/or/dirserv.h
index 46967a6cb,624cd7e0b..5f195442c
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@@ -190,19 -140,4 +190,18 @@@ int dirserv_read_measured_bandwidths(co
  int dirserv_read_guardfraction_file(const char *fname,
                                   smartlist_t *vote_routerstatuses);
  
 -#endif
 +spooled_resource_t *spooled_resource_new(dir_spool_source_t source,
 +                                         const uint8_t *digest,
 +                                         size_t digestlen);
 +spooled_resource_t *spooled_resource_new_from_cache_entry(
 +                                      struct consensus_cache_entry_t *entry);
 +void spooled_resource_free(spooled_resource_t *spooled);
 +void dirserv_spool_remove_missing_and_guess_size(dir_connection_t *conn,
 +                                                 time_t cutoff,
 +                                                 int compression,
 +                                                 size_t *size_out,
 +                                                 int *n_expired_out);
 +void dirserv_spool_sort(dir_connection_t *conn);
 +void dir_conn_clear_spool(dir_connection_t *conn);
 +
 +#endif /* !defined(TOR_DIRSERV_H) */
- 
diff --cc src/test/test_dir.c
index b21ce5048,4cdbfb4f8..28489d939
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@@ -6110,89 -5457,56 +6110,140 @@@ test_dir_assumed_flags(void *arg
  }
  
  static void
 +test_dir_post_parsing(void *arg)
 +{
 +  (void) arg;
 +
 +  /* Test the version parsing from an HS descriptor publish request. */
 +  {
 +    const char *end;
 +    const char *prefix = "/tor/hs/";
 +    int version = parse_hs_version_from_post("/tor/hs//publish", prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    version = parse_hs_version_from_post("/tor/hs/a/publish", prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    version = parse_hs_version_from_post("/tor/hs/3/publish", prefix, &end);
 +    tt_int_op(version, OP_EQ, 3);
 +    tt_str_op(end, OP_EQ, "/publish");
 +    version = parse_hs_version_from_post("/tor/hs/42/publish", prefix, &end);
 +    tt_int_op(version, OP_EQ, 42);
 +    tt_str_op(end, OP_EQ, "/publish");
 +    version = parse_hs_version_from_post("/tor/hs/18163/publish",prefix, &end);
 +    tt_int_op(version, OP_EQ, 18163);
 +    tt_str_op(end, OP_EQ, "/publish");
 +    version = parse_hs_version_from_post("JUNKJUNKJUNK", prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    version = parse_hs_version_from_post("/tor/hs/3/publish", "blah", &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    /* Missing the '/' at the end of the prefix. */
 +    version = parse_hs_version_from_post("/tor/hs/3/publish", "/tor/hs", &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    version = parse_hs_version_from_post("/random/blah/tor/hs/3/publish",
 +                                         prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    version = parse_hs_version_from_post("/tor/hs/3/publish/random/junk",
 +                                         prefix, &end);
 +    tt_int_op(version, OP_EQ, 3);
 +    tt_str_op(end, OP_EQ, "/publish/random/junk");
 +    version = parse_hs_version_from_post("/tor/hs/-1/publish", prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +    /* INT_MAX */
 +    version = parse_hs_version_from_post("/tor/hs/2147483647/publish",
 +                                         prefix, &end);
 +    tt_int_op(version, OP_EQ, INT_MAX);
 +    tt_str_op(end, OP_EQ, "/publish");
 +    /* INT_MAX + 1*/
 +    version = parse_hs_version_from_post("/tor/hs/2147483648/publish",
 +                                         prefix, &end);
 +    tt_int_op(version, OP_EQ, -1);
 +    tt_ptr_op(end, OP_EQ, NULL);
 +  }
 +
 + done:
 +  ;
 +}
 +
 +static void
 +test_dir_platform_str(void *arg)
 +{
 +  char platform[256];
 +  (void)arg;
 +  platform[0] = 0;
 +  get_platform_str(platform, sizeof(platform));
 +  tt_int_op((int)strlen(platform), OP_GT, 0);
 +  tt_assert(!strcmpstart(platform, "Tor "));
 +
 +  tor_version_t ver;
 +  // make sure this is a tor version, a real actual tor version.
 +  tt_int_op(tor_version_parse_platform(platform, &ver, 1), OP_EQ, 1);
 +
 +  TT_BLATHER(("%d.%d.%d.%d", ver.major, ver.minor, ver.micro, ver.patchlevel));
 +
 +  // Handle an example version.
 +  tt_int_op(tor_version_parse_platform(
 +        "Tor 0.3.3.3 (foo) (git-xyzzy) on a potato", &ver, 1), OP_EQ, 1);
 + done:
 +  ;
 +}
 +
++static void
+ test_dir_format_versions_list(void *arg)
+ {
+   (void)arg;
+   char *s = NULL;
+   config_line_t *lines = NULL;
+ 
+   setup_capture_of_logs(LOG_WARN);
+   s = format_recommended_version_list(lines, 1);
+   tt_str_op(s, OP_EQ, "");
+ 
+   tor_free(s);
+   config_line_append(&lines, "ignored", "0.3.4.1, 0.2.9.111-alpha, 4.4.4-rc");
+   s = format_recommended_version_list(lines, 1);
+   tt_str_op(s, OP_EQ,  "0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+ 
+   tor_free(s);
+   config_line_append(&lines, "ignored", "0.1.2.3,0.2.9.10   ");
+   s = format_recommended_version_list(lines, 1);
+   tt_str_op(s, OP_EQ,  "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+ 
+   /* There should be no warnings so far. */
+   expect_no_log_entry();
+ 
+   /* Now try a line with a space in it. */
+   tor_free(s);
+   config_line_append(&lines, "ignored", "1.3.3.8 1.3.3.7");
+   s = format_recommended_version_list(lines, 1);
+   tt_str_op(s, OP_EQ,  "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,"
+             "1.3.3.7,1.3.3.8,4.4.4-rc");
+ 
+   expect_single_log_msg_containing(
+           "Unexpected space in versions list member \"1.3.3.8 1.3.3.7\"." );
+ 
+   /* Start over, with a line containing a bogus version */
+   config_free_lines(lines);
+   lines = NULL;
+   tor_free(s);
+   mock_clean_saved_logs();
+   config_line_append(&lines, "ignored", "0.1.2.3, alpha-complex, 0.1.1.8-rc");
+   s = format_recommended_version_list(lines,1);
+   tt_str_op(s, OP_EQ, "0.1.1.8-rc,0.1.2.3,alpha-complex");
+   expect_single_log_msg_containing(
+         "Recommended version \"alpha-complex\" does not look valid.");
+ 
+  done:
+   tor_free(s);
+   config_free_lines(lines);
+   teardown_capture_of_logs();
+ }
+ 
  #define DIR_LEGACY(name)                             \
    { #name, test_dir_ ## name , TT_FORK, NULL, NULL }
  
@@@ -6250,17 -5557,11 +6301,17 @@@ struct testcase_t dir_tests[] = 
    DIR(dump_unparseable_descriptors, 0),
    DIR(populate_dump_desc_fifo, 0),
    DIR(populate_dump_desc_fifo_2, 0),
 -  DIR_ARG(find_dl_schedule, TT_FORK, "bf"),
 -  DIR_ARG(find_dl_schedule, TT_FORK, "ba"),
 -  DIR_ARG(find_dl_schedule, TT_FORK, "cf"),
 -  DIR_ARG(find_dl_schedule, TT_FORK, "ca"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "bfd"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "bad"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "cfd"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "cad"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "bfr"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "bar"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "cfr"),
 +  DIR_ARG(find_dl_schedule, TT_FORK, "car"),
    DIR(assumed_flags, 0),
 +  DIR(networkstatus_compute_bw_weights_v10, 0),
 +  DIR(platform_str, 0),
+   DIR(format_versions_list, TT_FORK),
    END_OF_TESTCASES
  };
- 





More information about the tor-commits mailing list