php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72426 Function registration logic within the Zend framework should use the same case
Submitted: 2016-06-15 21:56 UTC Modified: -
From: nathan dot justus at oracle dot com Assigned:
Status: Open Package: PHP options/info functions
PHP Version: 5.6.22 OS: Gnu Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 + 11 = ?
Subscribe to this entry?

 
 [2016-06-15 21:56 UTC] nathan dot justus at oracle dot com
Description:
------------
prior to calling zend_hash_add, zend_register_functions translates the “key” to lowercase.  Certainly there is nothing wrong with this approach, IF the corresponding code that searches for and removes the entry from the hash table is doing the same thing; otherwise, the hash codes will not match.
(gdb) bt
#0  _zend_hash_add_or_update (ht=0x8e827b0, arKey=0x8ef4be0 "initconnectapi", nKeyLength=15, pData=0x5e72c94, nDataSize=144, pDest=0x5e72c90, flag=2)
    at /nfs/local/src/php/php-5.3.2-1511_150610/Zend/zend_hash.c:208
#1  0x07a888fd in zend_register_functions (scope=0x0, functions=0x5db780, function_table=0x0, type=2, tsrm_ls=0x8e41038) at /nfs/local/src/php/php-5.3.2-1511_150610/Zend/zend_API.c:1930
#2  0x07a87ad9 in zend_register_module_ex (module=0x8f24c10, tsrm_ls=0x8e41038) at /nfs/local/src/php/php-5.3.2-

that is:

fname_len = strlen(ptr->fname);
lowercase_name = zend_str_tolower_dup(ptr->fname, fname_len);
if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)&reg_function) == FAILURE) {
        unload=1;
        efree(lowercase_name);
        break;
}

how the delete code does NOT translate the key to lowercase beforehand:
(gdb) bt
#0  zend_hash_del_key_or_index (ht=0x915b7b0, arKey=0x2d7d5a4 "initConnectAPI", nKeyLength=15, h=0, flag=0) at /nfs/local/src/php/php-5.3.2-1511_150610/Zend/zend_hash.c:462
#1  0x0058d205 in zend_unregister_functions (functions=0x2da6780, count=-1, function_table=0x0, tsrm_ls=0x911a038) at /nfs/local/src/php/php-5.3.2-1511_150610/Zend/zend_API.c:2091
#2  0x0058d3e4 in module_destructor (module=0x91fd9d0) at /

Either both or neither should use 'tolower.'


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 04:01:25 2019 UTC