diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-22 12:17:45 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-22 12:17:45 -0700 |
commit | 27bfd1211d64298ee3c3b2d82d7b38ca1e1167ad (patch) | |
tree | 487110ff5e0d85e185e842d2d9d1c23087029844 /plugins/OStatus/lib/safemath_biginteger.php | |
parent | 4168b9cec1f7b2e6421c018e56e3b9a13c14d581 (diff) |
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.
Diffstat (limited to 'plugins/OStatus/lib/safemath_biginteger.php')
-rw-r--r-- | plugins/OStatus/lib/safemath_biginteger.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/OStatus/lib/safemath_biginteger.php b/plugins/OStatus/lib/safemath_biginteger.php new file mode 100644 index 000000000..c05e24d1e --- /dev/null +++ b/plugins/OStatus/lib/safemath_biginteger.php @@ -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(); + } +} + |