]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Have correct_tm set tm_wday as well.
authorNick Mathewson <nickm@torproject.org>
Thu, 5 May 2016 14:49:55 +0000 (10:49 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 12 May 2016 18:37:27 +0000 (14:37 -0400)
The tm_wday field had been left uninitialized, which was causing
some assertions to fail on Windows unit tests.

Fixes bug 18977.

changes/bug18977 [new file with mode: 0644]
src/common/compat.c
src/common/util.c

diff --git a/changes/bug18977 b/changes/bug18977
new file mode 100644 (file)
index 0000000..3f46b09
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (time handling):
+    - When correcting a corrupt 'struct tm' value, fill in the tm_wday
+      field. Otherwise, our unit tests crash on Windows.
+      Fixes bug 18977; bugfix on 0.2.2.25-alpha.
index d88c5f92dec40ab8010c7640374f1bd1a5c3786d..90132fc1b0dbb6ff5a144644bd4c7d52b16b63c5 100644 (file)
@@ -2462,6 +2462,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_mon = 11;
       r->tm_mday = 31;
       r->tm_yday = 365;
+      r->tm_wday = 6;
       r->tm_hour = 23;
       r->tm_min = 59;
       r->tm_sec = 59;
@@ -2479,6 +2480,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_mon = 0;
       r->tm_mday = 1;
       r->tm_yday = 1;
+      r->tm_wday = 0;
       r->tm_hour = 0;
       r->tm_min = 0 ;
       r->tm_sec = 0;
@@ -2492,6 +2494,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
       r->tm_mon = 11;
       r->tm_mday = 31;
       r->tm_yday = 365;
+      r->tm_wday = 6;
       r->tm_hour = 23;
       r->tm_min = 59;
       r->tm_sec = 59;
index 5eb0f9a69bc8756a04a0bde631942f3dfd55b6d9..31dc2a4ec1eb2db4d5ac342a6b6837289d6c3f3e 100644 (file)
@@ -1460,6 +1460,7 @@ parse_iso_time(const char *cp, time_t *t)
   st_tm.tm_hour = hour;
   st_tm.tm_min = minute;
   st_tm.tm_sec = second;
+  st_tm.tm_wday = 0; /* Should be ignored. */
 
   if (st_tm.tm_year < 70) {
     char *esc = esc_for_log(cp);
@@ -1517,6 +1518,7 @@ parse_http_time(const char *date, struct tm *tm)
   tm->tm_hour = (int)tm_hour;
   tm->tm_min = (int)tm_min;
   tm->tm_sec = (int)tm_sec;
+  tm->tm_wday = 0; /* Leave this unset. */
 
   month[3] = '\0';
   /* Okay, now decode the month. */