]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Don't use "0" as a "base" argument to tor_parse_*().
authorNick Mathewson <nickm@torproject.org>
Wed, 9 Aug 2017 13:55:12 +0000 (09:55 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 28 Aug 2017 14:21:29 +0000 (10:21 -0400)
Telling these functions to autodetect the numeric base has lead to
trouble in the past.

Fixes bug 22469. Bugfix on 0.2.2.various.

changes/bug22802 [new file with mode: 0644]
src/common/procmon.c
src/or/circuitstats.c
src/or/dirserv.c

diff --git a/changes/bug22802 b/changes/bug22802
new file mode 100644 (file)
index 0000000..7255164
--- /dev/null
@@ -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.
+
+
index d49e7f18f5cd054e05f010c8b19f20713740a6b2..5ef16c726881f284a8fe402a6d0cb57ac90dae11 100644 (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
    * 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
    * (platform-specific) identifying information beyond the PID, to
index 51d580a1a4cc9b07aa804ebe38fca04cd6154e7a..963892c9d1a454ed7d0cfc4c6c6c62ea011cde5a 100644 (file)
@@ -939,7 +939,7 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
       uint32_t count, k;
       build_time_t ms;
       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);
       if (!ok) {
         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);
         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);
       if (!ok) {
         log_warn(LD_GENERAL, "Unable to parse circuit build times: "
index e5654e3b907fe1938c0652ff6ca15f614f64d20a..01f70858eac05de121a09ec23d5b08f3879d662b 100644 (file)
@@ -2700,7 +2700,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
       }
       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))) {
         log_warn(LD_DIRSERV, "Invalid bandwidth in bandwidth file line: %s",
                  escaped(orig_line));