From:             
Operating system: Linux
PHP version:      5.3.4
Package:          *Calendar problems
Bug Type:         Bug
Bug description:Integer overflow in SdnToJulian

Description:
------------
*cut*

void SdnToJulian(

                                        long int sdn,

                                        int *pYear,

                                        int *pMonth,

                                        int *pDay)

{

        int year;

        int month;

        int day;

        long int temp;

        int dayOfYear;



        if (sdn <= 0) {

                *pYear = 0;

                *pMonth = 0;

                *pDay = 0;

                return;

        }



        temp = (sdn + JULIAN_SDN_OFFSET) * 4 - 1;

*cut*



temp could here be less then 0 due to integer overflow (when sdn is large
enough).

Test script:
---------------
<?php

for(;;) {

    $x = rand(0, 2147483640);

    echo "$x\n";

    $dummy = cal_from_jd($x,0);

    $dummy = cal_from_jd($x,1);

}

?>



Expected result:
----------------
Sigsegv:



$ php core1.php 

758413092

1698116908

42935006

988939165

101976420

1332880082

882858043

Naruszenie ochrony pamięci (SIGSEGV)




-- 
Edit bug report at http://bugs.php.net/bug.php?id=53574&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53574&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53574&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53574&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53574&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53574&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53574&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53574&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53574&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53574&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53574&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53574&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53574&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53574&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53574&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53574&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53574&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53574&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53574&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53574&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53574&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53574&r=mysqlcfg

Reply via email to