Merge branch 'bug22802_squashed'

This commit is contained in:
Nick Mathewson 2017-08-28 10:23:05 -04:00
commit 4b4b3afb56
5 changed files with 14 additions and 12 deletions

10
changes/bug22802 Normal file
View File

@ -0,0 +1,10 @@
o Minor bugfixes (format strictness):
- Restrict several data formats to decimal. Previously, the
BuildTimeHistogram entries in the state file, the "bw=" entries in the
bandwidth authority file, and process IDs passed to the
__OwningControllerProcess option could all be specified in hex or octal
as well as in decimal. This was not an intentional feature.
Fixes bug 22802; bugfixes on 0.2.2.1-alpha, 0.2.2.2-alpha, and
0.2.2.28-beta.

View File

@ -71,7 +71,7 @@ parse_process_specifier(const char *process_spec,
/* If we're lucky, long will turn out to be large enough to hold a /* If we're lucky, long will turn out to be large enough to hold a
* PID everywhere that Tor runs. */ * PID everywhere that Tor runs. */
pid_l = tor_parse_long(process_spec, 0, 1, LONG_MAX, &pid_ok, &pspec_next); pid_l = tor_parse_long(process_spec, 10, 1, LONG_MAX, &pid_ok, &pspec_next);
/* Reserve room in the process specifier for additional /* Reserve room in the process specifier for additional
* (platform-specific) identifying information beyond the PID, to * (platform-specific) identifying information beyond the PID, to

View File

@ -1233,15 +1233,7 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
#ifdef HAVE_STRTOULL #ifdef HAVE_STRTOULL
r = (uint64_t)strtoull(s, &endptr, base); r = (uint64_t)strtoull(s, &endptr, base);
#elif defined(_WIN32) #elif defined(_WIN32)
#if defined(_MSC_VER) && _MSC_VER < 1300
tor_assert(base <= 10);
r = (uint64_t)_atoi64(s);
endptr = (char*)s;
while (TOR_ISSPACE(*endptr)) endptr++;
while (TOR_ISDIGIT(*endptr)) endptr++;
#else
r = (uint64_t)_strtoui64(s, &endptr, base); r = (uint64_t)_strtoui64(s, &endptr, base);
#endif
#elif SIZEOF_LONG == 8 #elif SIZEOF_LONG == 8
r = (uint64_t)strtoul(s, &endptr, base); r = (uint64_t)strtoul(s, &endptr, base);
#else #else

View File

@ -939,7 +939,7 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
uint32_t count, k; uint32_t count, k;
build_time_t ms; build_time_t ms;
int ok; int ok;
ms = (build_time_t)tor_parse_ulong(ms_str, 0, 0, ms = (build_time_t)tor_parse_ulong(ms_str, 10, 0,
CBT_BUILD_TIME_MAX, &ok, NULL); CBT_BUILD_TIME_MAX, &ok, NULL);
if (!ok) { if (!ok) {
log_warn(LD_GENERAL, "Unable to parse circuit build times: " log_warn(LD_GENERAL, "Unable to parse circuit build times: "
@ -949,7 +949,7 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
smartlist_free(args); smartlist_free(args);
break; break;
} }
count = (uint32_t)tor_parse_ulong(count_str, 0, 0, count = (uint32_t)tor_parse_ulong(count_str, 10, 0,
UINT32_MAX, &ok, NULL); UINT32_MAX, &ok, NULL);
if (!ok) { if (!ok) {
log_warn(LD_GENERAL, "Unable to parse circuit build times: " log_warn(LD_GENERAL, "Unable to parse circuit build times: "

View File

@ -2700,7 +2700,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
} }
cp+=strlen("bw="); cp+=strlen("bw=");
out->bw_kb = tor_parse_long(cp, 0, 0, LONG_MAX, &parse_ok, &endptr); out->bw_kb = tor_parse_long(cp, 10, 0, LONG_MAX, &parse_ok, &endptr);
if (!parse_ok || (*endptr && !TOR_ISSPACE(*endptr))) { if (!parse_ok || (*endptr && !TOR_ISSPACE(*endptr))) {
log_warn(LD_DIRSERV, "Invalid bandwidth in bandwidth file line: %s", log_warn(LD_DIRSERV, "Invalid bandwidth in bandwidth file line: %s",
escaped(orig_line)); escaped(orig_line));