#3880: integer overflow in date.c (mutt_mktime)
-----------------------+----------------------
  Reporter:  vinc17    |      Owner:  mutt-dev
      Type:  defect    |     Status:  new
  Priority:  critical  |  Milestone:
 Component:  mutt      |    Version:  1.7.0
Resolution:            |   Keywords:
-----------------------+----------------------

Comment (by code@…):

 None
 Filename untitled-part.sig could not be saved, problem: [Errno 13]
 Permission denied:
 
'/home/mutt/trac/files/attachments/ticket/4c0/4c0ca50acf1dba181d72e4ecfffaeb06d9ad64ac/90449eb29c8e1d56f09effe64f19fbf629d6557d.sig'\{{{
 Sadly, trac seems to have eaten the patch I attached via mail.

 I can't log into trac...  I've tried resetting the password years ago
 and even after doing that I was unable to.  At this point I no longer
 even remember the username I used to log in...

 So, here's the patch:


 diff -u -r mutt-1.7.0.orig/date.c mutt-1.7.0/date.c
 --- mutt-1.7.0.orig/date.c      2016-08-10 20:47:00.000000000 -0500
 +++ mutt-1.7.0/date.c   2016-10-22 09:54:17.812428765 -0500
 @@ -67,41 +67,9 @@
     account unless ``local'' is nonzero */
  time_t mutt_mktime (struct tm *t, int local)
  {
 -  time_t g;
 -
 -  static const int AccumDaysPerMonth[12] = {
 -    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
 -  };
 -
 -  /* Compute the number of days since January 1 in the same year */
 -  g = AccumDaysPerMonth [t->tm_mon % 12];
 -
 -  /* The leap years are 1972 and every 4. year until 2096,
 -   * but this algorithm will fail after year 2099 */
 -  g += t->tm_mday;
 -  if ((t->tm_year % 4) || t->tm_mon < 2)
 -    g--;
 -  t->tm_yday = g;
 -
 -  /* Compute the number of days since January 1, 1970 */
 -  g += (t->tm_year - 70) * 365;
 -  g += (t->tm_year - 69) / 4;
 -
 -  /* Compute the number of hours */
 -  g *= 24;
 -  g += t->tm_hour;
 -
 -  /* Compute the number of minutes */
 -  g *= 60;
 -  g += t->tm_min;
 -
 -  /* Compute the number of seconds */
 -  g *= 60;
 -  g += t->tm_sec;
 -
 -  if (local)
 +  time_t g = mktime(t);
 +  if (g != (time_t)-1 && local)
      g -= compute_tz (g, t);
 -
    return (g);
  }

 }}}

 [attachment:"untitled-part.sig"]

--
Ticket URL: <https://dev.mutt.org/trac/ticket/3880#comment:18>
Mutt <http://www.mutt.org/>
The Mutt mail user agent

Reply via email to