PHPASN1 icon indicating copy to clipboard operation
PHPASN1 copied to clipboard

PHPUnit tests fail on 32bit systems due to out-of-bounds integer.

Open lcts opened this issue 4 years ago • 0 comments

Hi, when running the test suite on 32bit systems (I tested on ARM & x86), tests fail with

There were 2 errors:

1) FG\Test\ASN1\Universal\BitStringTest::testContent
TypeError: dechex(): Argument #1 ($num) must be of type int, float given

/builddir/build/BUILDROOT/php-fgrosse-phpasn1-2.3.0-1.fc35.arm/usr/share/php/FG/ASN1/Universal/OctetString.php:28
/builddir/build/BUILDROOT/php-fgrosse-phpasn1-2.3.0-1.fc35.arm/usr/share/php/FG/ASN1/Universal/BitString.php:32
/builddir/build/BUILD/PHPASN1-20299033c35f4300eb656e7e8e88cf52d1d6694e/tests/ASN1/Universal/BitStringTest.php:45

2) FG\Test\ASN1\Universal\OctetStringTest::testContent
TypeError: dechex(): Argument #1 ($num) must be of type int, float given

/builddir/build/BUILDROOT/php-fgrosse-phpasn1-2.3.0-1.fc35.arm/usr/share/php/FG/ASN1/Universal/OctetString.php:28
/builddir/build/BUILD/PHPASN1-20299033c35f4300eb656e7e8e88cf52d1d6694e/tests/ASN1/Universal/OctetStringTest.php:45

I think what happens here is that the number used for testing, 0xA01200C3, exceeds PHP_INT_MAX on 32bit and so gets cast to float before being passed to dechex().

Is the library supposed to be able to deal with larger ints in there or is this just an error in the tests?

lcts avatar Aug 04 '21 11:08 lcts