apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1807976 - in /apr/apr/branches/1.6.x/time: unix/time.c win32/time.c
Date Sun, 10 Sep 2017 22:30:35 GMT
Author: niq
Date: Sun Sep 10 22:30:34 2017
New Revision: 1807976

URL: http://svn.apache.org/viewvc?rev=1807976&view=rev
Log:
Bounds-check human-readable date fields (credit: Stefan Sperling)

Modified:
    apr/apr/branches/1.6.x/time/unix/time.c
    apr/apr/branches/1.6.x/time/win32/time.c

Modified: apr/apr/branches/1.6.x/time/unix/time.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/time/unix/time.c?rev=1807976&r1=1807975&r2=1807976&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/time/unix/time.c (original)
+++ apr/apr/branches/1.6.x/time/unix/time.c Sun Sep 10 22:30:34 2017
@@ -142,6 +142,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_g
     static const int dayoffset[12] =
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
 
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+        return APR_EBADDATE;
+
     /* shift new year to 1st March in order to make leap year calc easy */
 
     if (xt->tm_mon < 2)

Modified: apr/apr/branches/1.6.x/time/win32/time.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/time/win32/time.c?rev=1807976&r1=1807975&r2=1807976&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/time/win32/time.c (original)
+++ apr/apr/branches/1.6.x/time/win32/time.c Sun Sep 10 22:30:34 2017
@@ -54,6 +54,9 @@ static void SystemTimeToAprExpTime(apr_t
     static const int dayoffset[12] =
     {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
 
+    if (tm->wMonth < 1 || tm->wMonth > 12)
+        return APR_EBADDATE;
+
     /* Note; the caller is responsible for filling in detailed tm_usec,
      * tm_gmtoff and tm_isdst data when applicable.
      */
@@ -224,6 +227,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_g
     static const int dayoffset[12] =
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
 
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+        return APR_EBADDATE;
+
     /* shift new year to 1st March in order to make leap year calc easy */
 
     if (xt->tm_mon < 2)



Mime
View raw message