Edit report at https://bugs.php.net/bug.php?id=63535&edit=1
ID: 63535
User updated by: lmpmbernardo at gmail dot com
Reported by: lmpmbernardo at gmail dot com
Summary: zend_parse_parameters: error when signature is
s|ssbs
Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: Ubuntu 12.04 LTS 32 bits
-PHP Version: 5.3.18
+PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
updated version; 5.3.10 is the most recent version in Ubuntu.
Previous Comments:
------------------------------------------------------------------------
[2012-11-16 00:46:13] lmpmbernardo at gmail dot com
Description:
------------
zend_parse_parameters is having trouble parsing this signature: s|ssbs; the
error happens with the last "bs" arguments. the signature "ssbs" works well.
~$ php -v
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli) (built: Sep 12 2012 19:00:43)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Test script:
---------------
PHP_FUNCTION(test_parse_parameters) {
char *p_str1 = "";
int p_str1_len;
char *p_str2 = "";
int p_str2_len;
char *p_str3 = "";
int p_str3_len;
zend_bool b = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ssbs", &p_str1,
&p_str1_len, &p_str2,
&p_str2_len, &b, &p_str3, &p_str3_len) == FAILURE) {
return;
}
zend_error(E_WARNING, "First parameter: len[%d] value[%s]", p_str1_len,
p_str1);
zend_error(E_WARNING, "Second parameter: len[%d] value[%s]", p_str2_len,
p_str2);
zend_error(E_WARNING, "Third parameter: '%s'", b ? "TRUE" : "FALSE");
zend_error(E_WARNING, "Fourth parameter: len[%d] value[%s]", p_str3_len,
p_str3);
char returnValue[256];
char* result;
sprintf(returnValue, "%d#%s", 0, "houston, we have a problem!");
result = estrdup(returnValue);
RETURN_STRING(result, 0);
}
Expected result:
----------------
lbernardo@sousel:~$ php -r 'echo test_parse_parameters("first", "second",
FALSE, "fourth");'
PHP Warning: First parameter: len[5] value[first] in Command line code on line
1
PHP Warning: Second parameter: len[6] value[second] in Command line code on
line 1
PHP Warning: Third parameter: 'FALSE' in Command line code on line 1
PHP Warning: Fourth parameter: len[6] value[fourth] in Command line code on
line 1
0#houston, we have a problem!
Actual result:
--------------
lbernardo@sousel:~$ php -r 'echo test_parse_parameters("first", "second",
FALSE, "fourth");'
PHP Warning: First parameter: len[5] value[first] in Command line code on line
1
PHP Warning: Second parameter: len[6] value[second] in Command line code on
line 1
PHP Warning: Third parameter: 'TRUE' in Command line code on line 1
PHP Warning: Fourth parameter: len[769] value[(null)] in Command line code on
line 1
0#houston, we have a problem!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63535&edit=1