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

[tor-commits] [tor/master] Use correct day of year in correct_tm()



commit dd556fb1e6002a0ca3c4560ecb8545696a82e0b9
Author: teor <teor2345@xxxxxxxxx>
Date:   Mon Oct 20 02:32:05 2014 +1100

    Use correct day of year in correct_tm()
    
    Set the correct day of year value in correct_tm() when the
    system's localtime(_r) or gmtime(_r) functions fail to set struct tm.
    
    Fixes bug 13476.
---
 changes/bug13476-improve-time-handling |    4 ++++
 src/common/compat.c                    |    6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/changes/bug13476-improve-time-handling b/changes/bug13476-improve-time-handling
new file mode 100644
index 0000000..3c50853
--- /dev/null
+++ b/changes/bug13476-improve-time-handling
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Set the correct day of year value when the system's localtime(_r)
+      or gmtime(_r) functions fail to set struct tm.
+      Fixes bug 13476.
diff --git a/src/common/compat.c b/src/common/compat.c
index 4dd0445..f8b1d15 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2774,7 +2774,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_year = 8099;
       r->tm_mon = 11;
       r->tm_mday = 31;
-      r->tm_yday = 365;
+      r->tm_yday = 364;
       r->tm_hour = 23;
       r->tm_min = 59;
       r->tm_sec = 59;
@@ -2791,7 +2791,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_year = 70; /* 1970 CE */
       r->tm_mon = 0;
       r->tm_mday = 1;
-      r->tm_yday = 1;
+      r->tm_yday = 0;
       r->tm_hour = 0;
       r->tm_min = 0 ;
       r->tm_sec = 0;
@@ -2804,7 +2804,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_year = 137; /* 2037 CE */
       r->tm_mon = 11;
       r->tm_mday = 31;
-      r->tm_yday = 365;
+      r->tm_yday = 364;
       r->tm_hour = 23;
       r->tm_min = 59;
       r->tm_sec = 59;



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