Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Rand bugfix #4982

Merged
merged 1 commit into from Aug 19, 2013
Merged

Rand bugfix #4982

merged 1 commit into from Aug 19, 2013

Conversation

superdweebie
Copy link
Contributor

This is a simple fix to enforce $length data type to be int in getBytes.

If the data type of $length is float (even if the float is an integer value) the this if fails: https://github.com/zendframework/zf2/blob/master/library/Zend/Math/Rand.php#L55 and can, in some php environments, result in this error being falsely thrown:
https://github.com/zendframework/zf2/blob/master/library/Zend/Math/Rand.php#L62

Just to add the quirk, the ciel function always returns a float, so this line https://github.com/zendframework/zf2/blob/master/library/Zend/Math/Rand.php#L187 can cause the faulty behavior (which is how I found the problem).

There is no test attached, because I don't know how to test for this properly due to it's environment specific nature. It will only show if ssl is not installed, and these alternatives are also not available: https://github.com/zendframework/zf2/blob/master/library/Zend/Math/Rand.php#L59

@ezimuel
Copy link
Contributor

ezimuel commented Aug 19, 2013

@superdweebie I think your proposal makes sense. The unit test is not mandatory in this case because the change is very simple and it's difficult to replicate because environment specific.

@ezimuel ezimuel merged commit 0901e78 into zendframework:develop Aug 19, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants