php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9366 bin2hex() outputs non-hex digits
Submitted: 2001-02-21 06:59 UTC Modified: 2001-05-03 11:02 UTC
From: gdambrosio at cspnet dot it Assigned:
Status: Closed Package: *Function Specific
PHP Version: 4.0.4pl1 OS: windows NT 4 (sp 4 or 5)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gdambrosio at cspnet dot it
New email:
PHP Version: OS:

 

 [2001-02-21 06:59 UTC] gdambrosio at cspnet dot it
it seems an unpredictable problem, I couldn't reproduce it with a string as input: I've attached a base64_encoded file containg the suitable binary data (I'm sorry it there was a simpler way);

I'm still not completely sure if it is due to bin2hex() or strstr(), but this latter is very unlikely;

this is the script:
just change the fopen() with the filename you want;

<?php

 $f1 = fopen( 'c:\\temp\\--->filename.bin','rb');
 //open the attached file

 $s = fread( $f1, 500000 );
 //read it all


 fclose($f1);

 $s2= bin2hex($s);

 echo "lung s2=".strlen($s2)."<br><br>";
 // displays correctly filesize()*2, that is 4412 * 2


 echo "s2=<<<$s2>>><br><br>";

 /*
 M$'IE5 displays not writeble characters:
 tryign to select the end of the string, I get evermore of it (just while I'm selecting !)
 but this should be a M$'bug; Netscape 4.03 works properly;
 */


 $ris= strstr( $s2, "0d0a0d0a") ;
 // I'm looking for the first occurrence of that string; I know it is on position x0176



 // -----> here's the problem:

 echo "lung ris= ".strlen($ris). "<br><br>";
 // I get variable results, between 8077 and 8083

 echo "ris=$ris<br><br>";
 /*
 I get again not writeble or "invisible" characters in IE5;
 on Netscape I get (eg) "04ffd9R" at the end of the string;
 */



?>



and this is the file (base64_encoded):


M0E4M0ZERjcgM0E2QURGRkIgM0E4NDMyN0QgMDAwMDAwMDAgMDAwMDBGQzIKWC1VUkw6IGh0dHA6Ly93d3cuYW56d2Vycy5uZXQvaG90L3lvdW5nb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Lr7b8HAFK0OYEYATThyWDFDTOb3SQjKWKOjqv1o2pwaGltxP4neKasNABVgTcBBBS1TIm3cUaCTqp85t3W/VTegbpmsaERRvegDJMwnSICLX1SAcuEBKnpfFdSSbkpkmyYQY7owlDCjBihp0041RSh3vL0McqzaRp4ibNCWBIp8Q4TwpYZGTZo3hkhmLTzBF2/e6y68W+189Lf6qKMyPaHRs1c0/g2WV8djaeSPR1DJWh7dCoWI1wTC9gg3rBPCTcWQYMswalUljLUTsxU7MXQuNgnObU3oudk7Qldd7mF/S+n0Tvi6R8kt2fWxtx2aW3sbHT5pXw0/kJ/XjF3Ny80vjT+T3aza50KR6htYLqdVKv266NPQX1OJyktEY5BitTCyoJTCUB610E/9k=



some ways to work around the problem are:
rewriting and re-reading the output of bin2hex;

or reconstructing the string piece by piece, with something like [$s2 is bin2hex' output] :

 for ($i=0; $i < strlen($s2); $i=$i+100 )
    {
    $ricostr = $ricostr.substr($s2,$i, 100);
    }

in both cases, the next step of the script (that looks for "0d0a0d0a") works right;

I've looked into the string.c but it seems fine, I don't know what to think;


thank you for any help, 
contact me if you need more infos,

bye,
Giuse









 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-21 07:33 UTC] gdambrosio at cspnet dot it
I've just found that the "reconstrunction" not ever works; only the rewrite/reread technique does;

bye again
 [2001-02-22 05:39 UTC] stas@php.net
Please see if current CVS snapshot fixes the problem.
 [2001-02-27 07:52 UTC] gdambrosio at cspnet dot it
I've tryed the 4.0.5-dev from www.php4win.de released on 20 febr. and I've got the same result; I'll work on compiling the latest CVS..
 [2001-02-27 08:00 UTC] stas@php.net
As you see, I wrote this comment on Feb. 22th, so please try
more recent version.
 [2001-04-10 10:07 UTC] sniper@php.net
No feedback. If this happens also with soon to be released PHP 4.0.5, reopen this bug report.

--Jani

 [2001-05-03 11:02 UTC] gdambrosio at cspnet dot it
(just informational)
ok, I think we can leave this closed;

with 4.0.5 I still get those "invisible" chars with IE5, but this should be a M$ bug;
Netscape or cURL work properly.

The length of the result string, strlen($ris), is now ever the same, also with IE;

I've re-tested the old file with 4.0.4 and 4.0.5-dev and still get the old errors
(posix 1003.3 FAIL);

--Giuse


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC