Mantis - Quercus
Viewing Issue Advanced Details
2119 minor always 10-26-07 20:01 10-29-07 14:12
koreth  
ferg  
normal  
closed 3.1.3  
fixed  
none    
none 3.1.4  
0002119: Binary values get altered when concatenated to a string
test/TestBinary.java:

package test;
import com.caucho.quercus.env.*;
class TestBinary {
        public static BinaryValue doTest() {
                byte[] testArray = new byte[1];
                testArray[0] = (byte)0x9c;
                return new BinaryBuilderValue(testArray);
        }
}

test.php:
<?php
import test.TestBinary;

$var = TestBinary::doTest();
$fp = fopen("/tmp/x", "w");
fwrite($fp, $var);
fwrite($fp, "x" . $var);
fclose($fp);

If you examine /tmp/x, you will see that the first fwrite() wrote the binary value, 0x9c. Then there's an "x" (0x78). Then, instead of another 0x9c, you'll see 0xfa.

If you change the $var assignment to "$var = chr(156);" then you get the correct output; this only seems to manifest with binary values returned by Java code (it bit me in some custom serialization code.)

Now that I've identified the problem I can work around it but it certainly seems like a bug.

Notes
(0002406)
ferg   
10-29-07 14:12   
php/0jdf