php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27258 gmp_powm: fix for bug #27172 breaks large (> 31 bit on i386) modulos
Submitted: 2004-02-15 01:14 UTC Modified: 2004-02-15 12:16 UTC
From: oscar at the-rileys dot net Assigned: iliaa (profile)
Status: Closed Package: Math related
PHP Version: 4CVS,5CVS OS: NetBSD 1.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oscar at the-rileys dot net
New email:
PHP Version: OS:

 

 [2004-02-15 01:14 UTC] oscar at the-rileys dot net
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-15 01:17 UTC] oscar at the-rileys dot net
I neglected to mention that this is vs. CVS snapshot 
200402142230.  The original bugfix that caused the 
problem was submitted on 2/8/04.
 [2004-02-15 12:16 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC