php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57830 wrong storage class for variable in C function gsrgs()
Submitted: 2007-09-09 08:04 UTC Modified: 2016-05-28 05:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hans at origin dot edvz dot uni-linz dot ac dot at Assigned: uchiyama
Status: Closed Package: stats (PECL)
PHP Version: 4.4.5 OS: Linux
Private report: No CVE-ID:
 [2007-09-09 08:04 UTC] hans at origin dot edvz dot uni-linz dot ac dot at
Description:
------------
in the sources of the PECL extension stats 1.0.2 we
need a 'static' storage class for the variable qinit:

File: stats-1.0.2/randlib.c
Function: void gsrgs(long getset,long *qvalue)

Original Code:
{
long qinit = 0;

Fixed Code:
{
/*MeJ: use static storage class ... otherwise 
       the value assigned to qinit gets lost upon
       return from function gsrgs()
*/
static long qinit = 0;



Reproduce code:
---------------
<?
stats_rand_setall ( 4711, 88888);
$val = stats_rand_gen_gamma ( 0.6, 0.1 );
?>


Expected result:
----------------
$val should be assigned a random float value 

Actual result:
--------------
X-Powered-By: PHP/4.4.5
Content-type: text/html

 INITGN called before random number generator  initialized -- abort!



Patches

fix_randlib.c_add_static (last revision 2013-11-01 10:09 UTC) by dev at example dot org)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-28 00:23 UTC] uchiyama@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: uchiyama
 [2016-05-28 05:21 UTC] uchiyama@php.net
-Status: Assigned +Status: Closed
 [2016-05-28 05:21 UTC] uchiyama@php.net
Fixed in version 1.0.4/2.0.2
 
PHP Copyright © 2001-2016 The PHP Group
All rights reserved.
Last updated: Sat Jul 30 18:01:41 2016 UTC