php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72450 INIT_CLASS_ENTRY macro should not use sizeof
Submitted: 2016-06-19 20:23 UTC Modified: 2017-07-12 14:34 UTC
From: slidertom at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.0.7 OS: Windows
Private report: No CVE-ID: None
 [2016-06-19 20:23 UTC] slidertom at gmail dot com
Description:
------------
INIT_CLASS_ENTRY macro should not use sizeof

e.g. such usage is valid:
INIT_CLASS_ENTRY(ce, "MyCustomClass", NULL);
as compiler uses such directives:
INIT_OVERLOADED_CLASS_ENTRY   (class_container, class_name,                       functions, NULL,        NULL,             NULL)
INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)

but if INIT_CLASS_ENTRY is used in the function like:
void InitClass(const char *class_name) {
   zend_class_entry ce;
  INIT_CLASS_ENTRY(ce, class_name, NULL);

will fail due the:
INIT_OVERLOADED_CLASS_ENTRY_EX define implementation:
sizeof(class_name)-1

maybe strlen (run-time) 
should be used to allow INIT_CLASS_ENTRY macro more general usage.






Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-12 14:34 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2017-07-12 14:34 UTC] ab@php.net
Thanks for the report. It is the intended implementation. You can always expand the macro, if you need some dynamics.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 14 22:01:31 2024 UTC