php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74017 gmp_export() gives wrong result
Submitted: 2017-01-30 16:46 UTC Modified: 2017-01-30 17:26 UTC
From: zhuravlov dot ip at ya dot ru Assigned:
Status: Not a bug Package: GNU MP related
PHP Version: 7.0.15 OS: Linux x86_64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zhuravlov dot ip at ya dot ru
New email:
PHP Version: OS:

 

 [2017-01-30 16:46 UTC] 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"



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-30 17:26 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2017-01-30 17:26 UTC] 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.
 [2023-10-31 22:08 UTC] aub2000 at rambler dot ru
Если это не ошибка а особенность реализации, то добавьте ваше текст в описание функции в php.net/manual
Я потратил много времени чтобы найти причину такого поведения функции.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 12:01:30 2024 UTC