diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/dirauth/bwauth.c | 10 | ||||
-rw-r--r-- | src/feature/dirauth/dirauth_config.c | 2 | ||||
-rw-r--r-- | src/lib/string/util_string.c | 2 | ||||
-rw-r--r-- | src/test/test_dir.c | 3 |
4 files changed, 12 insertions, 5 deletions
diff --git a/src/feature/dirauth/bwauth.c b/src/feature/dirauth/bwauth.c index 90b425842a..b5b1081e47 100644 --- a/src/feature/dirauth/bwauth.c +++ b/src/feature/dirauth/bwauth.c @@ -434,15 +434,19 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line, return -1; } got_bw=1; - } else if (strcmpstart(cp, "node_id=$") == 0) { + // Allow node_id to start with or without the dollar sign. + } else if (strcmpstart(cp, "node_id=") == 0) { if (got_node_id) { log_warn(LD_DIRSERV, "Double node_id= in bandwidth file line: %s", escaped(orig_line)); tor_free(line); return -1; } - cp+=strlen("node_id=$"); - + if (strcmpstart(cp, "node_id=$") == 0) { + cp+=strlen("node_id=$"); + } else if (strcmpstart(cp, "node_id=") == 0) { + cp+=strlen("node_id="); + } if (strlen(cp) != HEX_DIGEST_LEN || base16_decode(out->node_id, DIGEST_LEN, cp, HEX_DIGEST_LEN) != DIGEST_LEN) { diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c index 862ea9dafe..9378b0ffe6 100644 --- a/src/feature/dirauth/dirauth_config.c +++ b/src/feature/dirauth/dirauth_config.c @@ -471,7 +471,7 @@ dirauth_options_validate(const void *arg, char **msg) smartlist_split_string(version_sl, recommended_versions, ",", SPLIT_SKIP_SPACE, 0); SMARTLIST_FOREACH_BEGIN(version_sl, const char *, version) { - if (tor_version_parse(version, + if (version[0] != '\0' && tor_version_parse(version, &recommended_version) != 0) { COMPLAIN("Found unparseable version in RecommendedServerVersions"); continue; diff --git a/src/lib/string/util_string.c b/src/lib/string/util_string.c index b1c0a11439..60b5933e4d 100644 --- a/src/lib/string/util_string.c +++ b/src/lib/string/util_string.c @@ -31,6 +31,8 @@ tor_memmem(const void *_haystack, size_t hlen, { #if defined(HAVE_MEMMEM) && (!defined(__GNUC__) || __GNUC__ >= 2) raw_assert(nlen); + if (nlen > hlen) + return NULL; return memmem(_haystack, hlen, _needle, nlen); #else /* This isn't as fast as the GLIBC implementation, but it doesn't need to diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 87aaef7fe6..1811098440 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -2072,6 +2072,8 @@ test_dir_measured_bw_kb(void *arg) int i; const char *lines_pass[] = { "node_id=$557365204145532d32353620696e73746561642e bw=1024\n", + /* check whether node_id does not need the dollar sign at the start */ + "node_id=557365204145532d32353620696e73746561642e bw=1024\n", "node_id=$557365204145532d32353620696e73746561642e\t bw=1024 \n", " node_id=$557365204145532d32353620696e73746561642e bw=1024\n", "\tnoise\tnode_id=$557365204145532d32353620696e73746561642e " @@ -2129,7 +2131,6 @@ test_dir_measured_bw_kb(void *arg) " node_id= ", "node_id==$557365204145532d32353620696e73746561642e bw==1024\n", "node_id=$55736520414552d32353620696e73746561642e bw=1024\n", - "node_id=557365204145532d32353620696e73746561642e bw=1024\n", "node_id= $557365204145532d32353620696e73746561642e bw=0.23\n", /* Test that a line with vote=0 will fail too, so that it is ignored. */ |