|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-21 15:15 UTC] ivar at stvk dot no
Description: ------------ zend_make_printable_zval: Before returning with *use_copy=1, this function assumes that the preceding code has successfully converted the value to a sting, and therefore sets expr_copy->type = IS_STRING. If the original value IS_OBJECT, this function relies on any 3rd party cast handler to successfully return a string. Some libraries have been observed to break this rule, and return a value only initialized by ZVAL_NULL. This makes the system try to print a string from a garbage pointer. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 09:00:01 2025 UTC |
To reproduce the bug, use this script. Let 'TestDatabase' be any kind of database, and let the table field 'Table'.'NullField' be any database field that contains a NULL value. <?php try { $DB = new COM("ADODB.Connection") or die("Cannot start ADO"); $DB->Open("DRIVER={SQL Server};SERVER=SERVER\WEB;DATABASE=TestDatabase"); $RS = new COM("ADODB.Recordset"); $RS->Open("SELECT TEXT FROM Table", $DB); echo $RS["NullField"]; } catch (Exception $e) { echo $e->getTraceAsString() . "<br>"; echo $e->getMessage(); } ?>The only way I am able to reproduce this behavior is using COM, but the nature of the bug is not directly linked to the COM libraries itself. Because of this, I am unable to make a test case that is platform independent and that does not require external resources. I will try just once more: Create a Visual Basic ActiveX DLL project. Name the project 'NullClass', and name the class 'Null'. Add this single function to the class code: Public Property Get Value() Value = Null End Property Place the cursor inside the function, Click the menu "Tools", "Procedure Properties", "Advanced", and select "User Interface Default". Click "File", "Make NullClass.dll". Then run this PHP script: <?php $Obj = new COM('NullClass.Null'); echo $Obj; ?> EXPECTED: The script does not output anything, because the object contains a NULL value. ACTUAL: The script either outputs garbage or causes an Access Violation message.ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy) { ... ... case IS_OBJECT: { ... ... if (Z_OBJ_HANDLER_P(expr, cast_object)) { if( (Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) && (expr_copy->type == IS_STRING)) { break; } }