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

[tor-commits] [tor/release-0.3.0] Fix a logic error in hibernate.c



commit a6514b8a20b7a6fafb72bafad1e9c98a8e35cdee
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon May 15 11:43:18 2017 -0400

    Fix a logic error in hibernate.c
    
    Closes bug 22245; bugfix on 0.0.9rc1, when bandwidth accounting was
    first introduced.
    
    Found by Andrey Karpov and reported at https://www.viva64.com/en/b/0507/
---
 changes/bug22245   | 5 +++++
 src/or/hibernate.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug22245 b/changes/bug22245
new file mode 100644
index 000000000..6ae18593e
--- /dev/null
+++ b/changes/bug22245
@@ -0,0 +1,5 @@
+  o Minor bugfixes (bandwidth accounting):
+    - Roll over monthly accounting at the configured hour and minute,
+      rather than always at 00:00.
+      Fixes bug 22245; bugfix on 0.0.9rc1.
+      Found by Andrey Karpov with PVS-Studio.
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index a41257133..e5ed3d411 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -290,7 +290,7 @@ edge_of_accounting_period_containing(time_t now, int get_end)
     case UNIT_MONTH: {
       /* If this is before the Nth, we want the Nth of last month. */
       if (tm.tm_mday < cfg_start_day ||
-          (tm.tm_mday < cfg_start_day && before)) {
+          (tm.tm_mday == cfg_start_day && before)) {
         --tm.tm_mon;
       }
       /* Otherwise, the month is correct. */



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