Math_BigInteger doesn't correctly handle serialization/deserialization for a value of 0, which can end up spewing notices to output and otherwise intefering with Salmon signature setup and verification when using memcached.

Worked around this with a subclass that fixes the wakeup, used for the stored 0 value in the subclassed Crypt_RSA.
This commit is contained in:
Brion Vibber
2010-03-22 12:17:45 -07:00
parent 4168b9cec1
commit 27bfd1211d
3 changed files with 42 additions and 6 deletions

View File

@@ -0,0 +1,20 @@
<?php
require_once 'Math/BigInteger.php';
/**
* Crypt_RSA stores a Math_BigInteger with value 0, which triggers a bug
* in Math_BigInteger's wakeup function which spews notices to log or output.
* This wrapper replaces it with a version that survives serialization.
*/
class SafeMath_BigInteger extends Math_BigInteger
{
function __wakeup()
{
if ($this->hex == '') {
$this->hex = '0';
}
parent::__wakeup();
}
}