mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01:00
A `BSTR` is similar to a `zend_string`; it stores the length of the string just before the actual string, and thus the string may contain NUL bytes. However, `php_com_olestring_to_string()` is supposed to deal with arbitrary `OLECHAR*`s which may not be `BSTR`s, so we introduce `php_com_bstr_to_string()` and use it for the only case where we actually have to deal with `BSTR`s which may contain NUL bytes. Contrary to `php_com_olestring_to_string()` we return a `zend_string`, so we can save the re-allocation when converting to a `zval`. We also cater to `php_com_string_to_olestring()` not being binary safe, with basically the same fix we did for `php_com_olestring_to_string()`.
18 lines
455 B
PHP
18 lines
455 B
PHP
--TEST--
|
|
Bug #63208 (BSTR to PHP string conversion not binary safe)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$string = "\u{0905}b\0cd";
|
|
$variant = new VARIANT($string, VT_ARRAY | VT_UI1, CP_UTF8); // Array of bytes
|
|
$converted = (string) $variant;
|
|
var_dump(bin2hex($string));
|
|
var_dump(bin2hex($converted));
|
|
?>
|
|
--EXPECT--
|
|
string(14) "e0a48562006364"
|
|
string(14) "e0a48562006364"
|