summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2011-09-26 22:38:21 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2011-09-26 22:38:21 +0000
commit43f215a463edc2c5264a7efc20a89695c8cc7091 (patch)
treecef457fa477a92fc25aba69c030edd1a13d87b0d /ext
parent5ad03cd41a2815d921be371db29c32b9b02d7b6a (diff)
downloadphp-git-43f215a463edc2c5264a7efc20a89695c8cc7091.tar.gz
- Fixed bug in SdnToGregorian (see comments on #53574, though that bug is about
another function). NEWS & tests tomorrow.
Diffstat (limited to 'ext')
-rw-r--r--ext/calendar/gregor.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c
index c9c0bf761b..cf9860366c 100644
--- a/ext/calendar/gregor.c
+++ b/ext/calendar/gregor.c
@@ -127,6 +127,7 @@
**************************************************************************/
#include "sdncal.h"
+#include <limits.h>
#define GREGOR_SDN_OFFSET 32045
#define DAYS_PER_5_MONTHS 153
@@ -146,19 +147,14 @@ void SdnToGregorian(
long int temp;
int dayOfYear;
- if (sdn <= 0) {
- *pYear = 0;
- *pMonth = 0;
- *pDay = 0;
- return;
+ if (sdn <= 0 ||
+ sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
+ goto fail;
}
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
if (temp < 0) {
- *pYear = 0;
- *pMonth = 0;
- *pDay = 0;
- return;
+ goto fail;
}
/* Calculate the century (year/100). */
@@ -190,6 +186,10 @@ void SdnToGregorian(
*pYear = year;
*pMonth = month;
*pDay = day;
+fail:
+ *pYear = 0;
+ *pMonth = 0;
+ *pDay = 0;
}
long int GregorianToSdn(