Ask a Question related to PHP Bugs, Design and Development.
-
fjortiz at comunet dot es #1
#37899 [Com]: [PATCH] php_char_to _OLECHAR copies junk bytes
ID: 37899
Comment by: fjortiz at comunet dot es
Reported By: okumurya at hotmail dot com
Status: Assigned
Bug Type: COM related
Operating System: Windows 2000 Professional
PHP Version: 4.4.2
Assigned To: wez
New Comment:
Any updates on this issue?. We tracked down one problem we had with
ADODBCommand COM objects and Russian UTF-8 strings and found this was
the bug that was causing it.
Mr. Okumurya, please one question: did your last patch work for you?
Thanks in advance.
Previous Comments:
------------------------------------------------------------------------
[2006-07-03 07:31:00] okumurya at hotmail dot com
I misunderstand.
Revised patch is following.
--- ext\com\conversion.c.orig 2006-01-01 22:46:50.000000000 +0900
+++ ext\com\conversion.c 2006-06-23 14:01:42.838476800 +0900
@@ -247,8 +247,9 @@
case VT_BSTR:
convert_to_string_ex(&pval_arg);
+
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg),
Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str,
Z_STRLEN_P(pval_arg) * sizeof(OLECHAR));
+ V_BSTR(var_arg) = SysAllocString(unicode_str);
efree(unicode_str);
break;
@@ -787,20 +788,15 @@
{
BOOL error = FALSE;
OLECHAR *unicode_str;
+ uint unicode_strlen;
- if (strlen == -1) {
- /* request needed buffersize */
- strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 :
MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0);
- } else {
- /* \0 terminator */
- strlen++;
- }
+ unicode_strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ?
0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0);
- if (strlen >= 0) {
- unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen);
+ if (unicode_strlen > 0) {
+ unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) *
unicode_strlen);
/* convert string */
- error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 :
MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, strlen, unicode_str,
strlen);
+ error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 :
MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, unicode_str,
unicode_strlen);
} else {
/* return a zero-length string */
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR));
------------------------------------------------------------------------
[2006-06-23 05:09:36] okumurya at hotmail dot com
Description:
------------
In UTF-8, 'Z_STRLEN_P(pval_arg) * sizeof(OLECHAR)' is longer than
Widechar.
So SysAllocStringByteLen copies junk datas.
following is a patch.
--- conversion.c.orig 2006-06-23 11:28:06.496027200 +0900
+++ conversion.c 2006-06-23 14:01:42.838476800 +0900
@@ -247,8 +247,9 @@
case VT_BSTR:
convert_to_string_ex(&pval_arg);
+
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg),
Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str,
Z_STRLEN_P(pval_arg) * sizeof(OLECHAR));
+ V_BSTR(var_arg) = SysAllocString(unicode_str);
efree(unicode_str);
break;
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=37899&edit=1[/url]
fjortiz at comunet dot es Guest
-
#37899 [Asn]: [PATCH] php_char_to _OLECHAR copies junk bytes
ID: 37899 User updated by: okumurya at hotmail dot com Reported By: okumurya at hotmail dot com Status: Assigned... -
XML::Twig parser junk.
Hi, I'm trying to use XML::Twig to insert dates into <unitdate> tags to create an EAD finding aid, but I'm running into a strang XML::Twig parser... -
XML error: junk after document element
I am trying to parse and xml document: <?xml version="1.0"?> <!DOCTYPE PrequalResponse PUBLIC "-//New Edge Networks//DTD Pilot Prequalification... -
One Man's Junk
Some cameras which were rescued from dusty shelves and the junk heap. http://www.oceans-away.com/camera/ -
Junk mail on the list.
I'm getting a lot of junk mail that is addressed to this list. Am I the only one getting this stuff? alex -- To UNSUBSCRIBE, email to...



Reply With Quote

