From:             gopeyx at gmail dot com
Operating system: Windows NT W-AM-13079 6.1 build 
PHP version:      5.3.17
Package:          COM related
Bug Type:         Bug
Bug description:Wrong conversion of byte array VARIANT which contains null byte 
to string

Description:
------------
I have a VARIANT of type 8209 which is an array of bytes (VT_ARRAY |
VT_UI1).
This array contains null byte in the middle.

When trying to convert it to a string only bytes before null byte are used.
Others are ignored.

But they are present in the object. You can see it if you walk through the
bytes of variant via foreach().

Test script:
---------------
<?php

$string = "ab\0cd";

$variant = new VARIANT($string, VT_ARRAY | VT_UI1); // Array of bytes

$converted = (string) $variant;

var_dump($string);
var_dump($converted);


Expected result:
----------------
string(5) "abcd"
string(5) "abcd"

// $converted variable should be equal to the original $string and should
contain 5 characters.

Actual result:
--------------
string(5) "abcd"
string(2) "ab"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63208&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63208&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63208&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63208&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63208&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63208&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63208&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63208&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63208&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63208&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63208&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63208&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63208&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63208&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63208&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63208&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63208&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63208&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63208&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63208&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63208&r=mysqlcfg

Reply via email to