Date: 05/08/00
- Next message: zdoorduy <email protected>: "[PHP-DEV] PHP 4.0 Bug #4354: inetinfo.exe crashes after reboot"
- Previous message: chrism <email protected>: "[PHP-DEV] PHP 4.0 Bug #4358: new XOR breaks compatibility with php3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: alex.shepherd <email protected>
Operating system: Debian Linux 2.2.14
PHP version: 4.0 Release Candidate 1
PHP Bug Type: Other
Bug description: Informix LVARCHAR fields returned from ifx_fetch_row() are too long
We are using PHP4RC1 with Informix 9.2 on Linux. I have just noticed something that was causing a problem when LVARCHAR fields are returned into a Row array.
The PHP string that a LVARCHAR field is returned into seems to have two extra NULLs on the end which was causing some other problems in our application. I have tried CHAR(255) and VERCHAR(255) which seem to work fine as the add_assoc_string() function uses strlen() to determine its length where as LVARCHAR uses add_assoc_stringl() which relies upon the passed length parameter.
To debug the problem I modified the following section of the code (lines 2116-2128 of ifx.ec) to cause a warning:
case SQLLVARCHAR:
ifx_var_flag(&lvar_tmp,1);
EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :lvar_tmp = DATA;
fieldleng=ifx_var_getlen(&lvar_tmp);
if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
php_error(E_WARNING, "Out of memory");
RETURN_FALSE;
}
//----Begin Debug Code Here---------
php_error(E_WARNING,"ifx_fetch_row: SQLLVARCHAR ifx_var_getlen: %d strlen: %d", fieldleng, strlen( ifx_var_getdata(&lvar_tmp) ) ) ;
//----End Debug Code Here---------
memcpy(char_data,ifx_var_getdata(&lvar_tmp),fieldleng);
ifx_var_dealloc(&lvar_tmp);
add_assoc_stringl(return_value, fieldname, char_data, fieldleng,0);
break;
This causes the following line to be displayed in the browser:
Warning: ifx_fetch_row: SQLLVARCHAR ifx_var_getlen: 12 strlen: 10 in ifx_session.inc on line 110.
I had a look around in the ESQL/C manuals etc and they say the the call ifx_var_getlen() returns the size of a buffer needed to store the field data. My guess is that this includs a 16bit length word as well as the actual string and whould explain the two extra NULL chars.
To solve my imediate problem I have added 2 lines at line 2121 of ifx.ec:
fieldleng=ifx_var_getlen(&lvar_tmp);
//----Begin Hack to Fix Problem---------
if( fieldleng > 2 )
fieldleng -= 2 ;
//----End Hack to Fix Problem---------
if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: zdoorduy <email protected>: "[PHP-DEV] PHP 4.0 Bug #4354: inetinfo.exe crashes after reboot"
- Previous message: chrism <email protected>: "[PHP-DEV] PHP 4.0 Bug #4358: new XOR breaks compatibility with php3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

