Bug #74017 [Com]: gmp_export() gives wrong result
Edit report at https://bugs.php.net/bug.php?id=74017&edit=1
ID: 74017
Comment by: aub2000 at rambler dot ru
Reported by: zhuravlov dot ip at ya dot ru
Summary: gmp_export() gives wrong result
Status: Not a bug
Type: Bug
Package: GNU MP related
Operating System: Linux x86_64
PHP Version: 7.0.15
Block user comment: N
Private report: N
New Comment:
ÐÑли ÑÑо не оÑибка а
оÑобенноÑÑÑ ÑеализаÑии, Ñо
добавÑÑе ваÑе ÑекÑÑ Ð²
опиÑание ÑÑнкÑии в php.net/manual
Я поÑÑаÑил много вÑемени
ÑÑÐ¾Ð±Ñ Ð½Ð°Ð¹Ñи пÑиÑÐ¸Ð½Ñ Ñакого
Ð¿Ð¾Ð²ÐµÐ´ÐµÐ½Ð¸Ñ ÑÑнкÑии.
Previous Comments:
------------------------------------------------------------------------
[2017-01-30 17:26:49] nikic@php.net
The result is intentional. 0 returns "" instead of "\x00" in the same way that
255 returns "\xff" and not "\x00\xff". Additionally, returning an empty string
is consistent with the behavior of mpz_export(), which is spec'd to yield a zero count for a
zero op.
------------------------------------------------------------------------
[2017-01-30 16:46:19] zhuravlov dot ip at ya dot ru
Description:
------------
Distro: openSUSE Leap 42.1 (x86_64)
Packages used:
php7-7.0.15-35.2.x86_64
php7-gmp-7.0.15-35.2.x86_64
Standard (not changed) php.ini
Description:
The function gmp_export() gives wrong result for certain input: if the argument supplied is 0 or
gmp_init(0) then gmp_export() outputs empty string.
Test script:
---------------
<?php
echo gmp_export( 0 ); // will output '', must be "\x0"
echo gmp_export(gmp_init(0)); // will output '', must be "\x0"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74017&edit=1
Thread (3 messages)