From: oscar at the-rileys dot net Operating system: NetBSD 1.6 PHP version: 5CVS-2004-02-15 (dev) PHP Bug Type: Unknown/Other Function Bug description: gmp_powm: fix for bug #27172 breaks large (> 31 bit on i386) modulos
Description: ------------ The fix for bug #27172 (possible floating-point exception in gmp_powm) breaks the function with modulos longer than 31 bits. This is because the modulo argument is converted (destructively) to a long before it is fetched as a GMP number. The problem is rectified by moving the block that checks for a zero modulo to a point after the argument is fetched for use in the function. I have posted a diff here: http://oscar.the-rileys.net/php5-gpm_powm-patch.diff I have tested this on my own server, and it appears to fix the problem with at least 1024-bit modulos and still guards against 0 modulos - test for yourself to be sure, of course, Reproduce code: --------------- This is the example code from the documentation page for gpm_powm: <?php $pow1 = gmp_powm("2", "31", "2147483649"); echo gmp_strval($pow1) . "\n"; ?> Expected result: ---------------- The number 2147483648 should be output. Actual result: -------------- The number 1 is output. -- Edit bug report at http://bugs.php.net/?id=27258&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27258&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27258&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27258&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27258&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27258&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27258&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27258&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27258&r=support Expected behavior: http://bugs.php.net/fix.php?id=27258&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27258&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27258&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27258&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27258&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27258&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27258&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27258&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27258&r=float