From:             
Operating system: fedora core 16 x64
PHP version:      5.3.9
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:zend_parse_parameters(): Incorrect parsing of the first 
parameter

Description:
------------
Incorrect parsing of the first parameter if it's 
has type of 'string' and one of next parameter  has type of  'long'. 
Function zend_parse_parameters() always return string length as 0 of first

parameter. Error is present in versions 5.3.7-5.3.9. In version 5.3.6 there
is 
no error

On php v 5.3.6 it's correctly  works

Example 1 (Error):

PHP_FUNCTION(test_parse_parameters) {
    char *p_str1 = NULL;
    char *p_str2 = NULL;
    
    int p_long;
    int p_str1_len;
    int p_str2_len;

  if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sls", 
&p_str1, &p_str1_len, &p_long, &p_str2, &p_str2_len)) {
        return;
  }

    zend_error(E_WARNING, "First parameter: '%s' and it len: %d", p_str1, 
p_str1_len);  
    zend_error(E_WARNING, "Second parameter: '%d'", p_long);  
    zend_error(E_WARNING, "Third parameter: '%s' and it len: %d", p_str2, 
p_str2_len);
}

Run:
[antonio@antonio]# php -r 'test_parse_parameters("first", 123, "third");'

Output:

>>> PHP Warning:  First parameter: 'first' and it len: 0 in Command line
code on 
line 1 <<<
PHP Warning:  Second parameter: '123' in Command line code on line 1
PHP Warning:  Third parameter: 'third' and it len: 5 in Command line code
on 
line 1


Exemple 2 (Error):

PHP_FUNCTION(test_parse_parameters) {
  char *p_str1 = NULL;
  char *p_str2 = NULL;

  int p_str1_len;
  int p_str2_len;
  int p_long;

  if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", 
&p_str1, &p_str1_len, &p_str2, &p_str2_len, &p_long)) {
        return;
    }

    zend_error(E_WARNING, "First parameter: '%s' and it len: %d", p_str1, 
p_str1_len);      
    zend_error(E_WARNING, "Second parameter: '%s' and it len: %d", p_str2,

p_str2_len);
    zend_error(E_WARNING, "Third parameter: '%d'", p_long);
}

Run:

[antonio@antonio]# php -r 'dwavd_init("first", "second", 123);'

Output:

>>> PHP Warning:  First parameter: 'first' and it len: 0 in Command line
code on 
line 1 <<<
PHP Warning:  Second parameter: 'second' and it len: 6 in Command line code
on 
line 1
PHP Warning:  Third parameter: '123' in Command line code on line 1


Exemple 3 (OK):

PHP_FUNCTION(test_parse_parameters) {
  char *p_str1 = NULL;
  char *p_str2 = NULL;

  int p_str1_len;
  int p_str2_len;

  if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
&p_str1, 
&p_str1_len, &p_str2, &p_str2_len)) {
        return;
  }

    zend_error(E_WARNING, "First parameter: '%s' and it len: %d", p_str1, 
p_str1_len);      
    zend_error(E_WARNING, "Second parameter: '%s' and it len: %d", p_str2,

p_str2_len);
}

Run:

[antonio@antonio]#  php -r 'test_parse_parameters("first", "second");'

Output:

PHP Warning:  First parameter: 'first' and it len: 5 in Command line code
on 
line 1
PHP Warning:  Second parameter: 'second' and it len: 6 in Command line code
on 
line 1


Exemple 4 (OK):

PHP_FUNCTION(test_parse_parameters) {
  char *p_str1 = NULL;
  char *p_str2 = NULL;

  int p_str1_len;
  int p_str2_len;
  int p_long;

  if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lss", 
&p_long, &p_str1, &p_str1_len, &p_str2, &p_str2_len)) {
        return;
    }
    
    zend_error(E_WARNING, "First parameter: '%d'", p_long);  
    zend_error(E_WARNING, "Second parameter: '%s' and it len: %d", p_str1,

p_str1_len);      
    zend_error(E_WARNING, "Third parameter: '%s' and it len: %d", p_str2, 
p_str2_len);
}

Run:

[antonio@antonio]#  php -r 'test_parse_parameters(123, "second",
"third");'

Output:

PHP Warning:  First parameter: '123' in Command line code on line 1
PHP Warning:  Second parameter: 'second' and it len: 5 in Command line code
on 
line 1
PHP Warning:  Third parameter: 'third' and it len: 6 in Command line code
on 
line 1



-- 
Edit bug report at https://bugs.php.net/bug.php?id=60725&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60725&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60725&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60725&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60725&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60725&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60725&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60725&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60725&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60725&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60725&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60725&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60725&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60725&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60725&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60725&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60725&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60725&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60725&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60725&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60725&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60725&r=mysqlcfg

Reply via email to