]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Limit version numbers to 0...INT32_MAX.
authorNick Mathewson <nickm@torproject.org>
Wed, 15 Feb 2017 12:57:34 +0000 (07:57 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 15 Feb 2017 12:57:34 +0000 (07:57 -0500)
Closes 21450; patch from teor.

changes/bug21450 [new file with mode: 0644]
src/or/routerparse.c

diff --git a/changes/bug21450 b/changes/bug21450
new file mode 100644 (file)
index 0000000..a1cf89a
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (voting consistency):
+    - Reject version numbers with components that exceed INT32_MAX.
+      Otherwise 32-bit and 64-bit platforms would behave inconsistently.
+      Fixes bug 21450; bugfix on 0.0.8pre1.
index a896dde2b3a30b0bfeaa9e426e2f4227eddbe5df..c325412e396ea98da1ce5709b810442eb9e53fd0 100644 (file)
@@ -5605,6 +5605,7 @@ tor_version_parse(const char *s, tor_version_t *out)
 {
   char *eos=NULL;
   const char *cp=NULL;
+  int ok = 1;
   /* Format is:
    *   "Tor " ? NUM dot NUM [ dot NUM [ ( pre | rc | dot ) NUM ] ] [ - tag ]
    */
@@ -5620,7 +5621,9 @@ tor_version_parse(const char *s, tor_version_t *out)
 
 #define NUMBER(m)                               \
   do {                                          \
-    out->m = (int)strtol(cp, &eos, 10);         \
+    out->m = (int)tor_parse_uint64(val, 10, 0, INT32_MAX, &ok, &eos); \
+    if (!ok)                                    \
+      return -1;                                \
     if (!eos || eos == cp)                      \
       return -1;                                \
     cp = eos;                                   \