[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.2] Provide correct timeradd/timersup replacements



commit da876aec63b133b64eb6e71f8b87df5c84e7ec3b
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date:   Sun Dec 25 23:19:08 2011 +0100

    Provide correct timeradd/timersup replacements
    
    Bug caught and patch provided by Vektor. Fixes bug 4778.t
---
 changes/timersub_bug |    7 +++++++
 src/common/compat.h  |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/changes/timersub_bug b/changes/timersub_bug
new file mode 100644
index 0000000..9183862
--- /dev/null
+++ b/changes/timersub_bug
@@ -0,0 +1,7 @@
+  o Major bugfixes:
+    - Provide correct replacements for the timeradd() and timersub() functions
+      for platforms that lack them (for example, windows). The timersub()
+      function is used when expiring circuits, timeradd() is currently unused.
+      Patch written by Vektor, who also reported the bug. Thanks! Bugfix
+      on 0.2.2.24-alpha/0.2.3.1-alpha, fixes bug 4778.
+
diff --git a/src/common/compat.h b/src/common/compat.h
index 3e1b5b8..e0b074c 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -334,7 +334,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
 #define timeradd(tv1,tv2,tvout) \
   do {                                                  \
     (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec;    \
-    (tvout)->tv_usec = (tv2)->tv_usec + (tv2)->tv_usec; \
+    (tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \
     if ((tvout)->tv_usec >= 1000000) {                  \
       (tvout)->tv_usec -= 1000000;                      \
       (tvout)->tv_sec++;                                \
@@ -348,7 +348,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
 #define timersub(tv1,tv2,tvout) \
   do {                                                  \
     (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec;    \
-    (tvout)->tv_usec = (tv2)->tv_usec - (tv2)->tv_usec; \
+    (tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec; \
     if ((tvout)->tv_usec < 0) {                         \
       (tvout)->tv_usec += 1000000;                      \
       (tvout)->tv_sec--;                                \



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits