]> granicus.if.org Git - php/commitdiff
Fix integer overflow in calender.
authorJoshua Rogers <git@internot.info>
Mon, 19 Jan 2015 10:31:15 +0000 (21:31 +1100)
committerJoe Watkins <krakjoe@php.net>
Sat, 12 Nov 2016 17:33:51 +0000 (17:33 +0000)
Fix int overflows in conversation functions for calendar.
Add tests for the overflows.

ext/calendar/calendar.c
ext/calendar/gregor.c
ext/calendar/julian.c
ext/calendar/tests/gregoriantojd_overflow.phpt [new file with mode: 0644]
ext/calendar/tests/juliantojd_overflow.phpt [new file with mode: 0644]

index 40ae249cdabf77a8eb21be7357efd5ea84bbd6c0..47f2c1dd54306917811165713cc97bf0f784fb94 100644 (file)
@@ -12,7 +12,7 @@
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Authors: Shane Caraveo             <shane@caraveo.com>               | 
+   | Authors: Shane Caraveo             <shane@caraveo.com>               |
    |          Colin Viebrock            <colin@easydns.com>               |
    |          Hartmut Holzgraefe        <hholzgra@php.net>                |
    |          Wez Furlong               <wez@thebrainroom.com>            |
index 069fe6eb5ae7160dfae0fd62d9bdf28987953cd7..4c91fa8d540084a6d262ff76798574b5066b037c 100644 (file)
@@ -195,7 +195,7 @@ zend_long GregorianToSdn(
                                                   int inputMonth,
                                                   int inputDay)
 {
-       int year;
+       zend_long year;
        int month;
 
        /* check for invalid dates */
index 904727ff0424a2e35ba23e6bc2b9f70455aad779..6ab0854c3be7730832d56ff89a6d4c76971ea5ae 100644 (file)
@@ -217,7 +217,7 @@ zend_long JulianToSdn(
                                                int inputMonth,
                                                int inputDay)
 {
-       int year;
+       zend_long year;
        int month;
 
        /* check for invalid dates */
diff --git a/ext/calendar/tests/gregoriantojd_overflow.phpt b/ext/calendar/tests/gregoriantojd_overflow.phpt
new file mode 100644 (file)
index 0000000..a189cc8
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+gregoriantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo gregoriantojd(5, 5, 6000000) . "\n";
+?>
+--EXPECT--
+2193176185
diff --git a/ext/calendar/tests/juliantojd_overflow.phpt b/ext/calendar/tests/juliantojd_overflow.phpt
new file mode 100644 (file)
index 0000000..f2f5aa1
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+juliantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo juliantojd(5, 5, 6000000000) . "\n";
+?>
+--EXPECT--
+622764916319