main/SAPI: make "ini_entries" a const string

This commit is contained in:
Max Kellermann 2022-03-22 21:58:06 +01:00 committed by George Peter Banyard
parent 2d662f325d
commit d53ad4b566
3 changed files with 5 additions and 10 deletions

View file

@ -262,7 +262,7 @@ struct _sapi_module_struct {
void (*ini_defaults)(HashTable *configuration_hash); void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text; int phpinfo_as_text;
char *ini_entries; const char *ini_entries;
const zend_function_entry *additional_functions; const zend_function_entry *additional_functions;
unsigned int (*input_filter_init)(void); unsigned int (*input_filter_init)(void);
}; };

View file

@ -214,8 +214,7 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
* allocated so any INI settings added via this callback will have the * allocated so any INI settings added via this callback will have the
* lowest precedence and will allow INI files to overwrite them. * lowest precedence and will allow INI files to overwrite them.
*/ */
php_embed_module.ini_entries = malloc(sizeof(HARDCODED_INI)); php_embed_module.ini_entries = HARDCODED_INI;
memcpy(php_embed_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
/* SAPI-provided functions. */ /* SAPI-provided functions. */
php_embed_module.additional_functions = additional_functions; php_embed_module.additional_functions = additional_functions;
@ -264,9 +263,4 @@ EMBED_SAPI_API void php_embed_shutdown(void)
#ifdef ZTS #ifdef ZTS
tsrm_shutdown(); tsrm_shutdown();
#endif #endif
if (php_embed_module.ini_entries) {
free(php_embed_module.ini_entries);
php_embed_module.ini_entries = NULL;
}
} }

View file

@ -144,7 +144,8 @@ int fuzzer_init_php(const char *extra_ini)
if (extra_ini) { if (extra_ini) {
ini_len += extra_ini_len + 1; ini_len += extra_ini_len + 1;
} }
char *p = fuzzer_module.ini_entries = malloc(ini_len + 1); char *p = malloc(ini_len + 1);
fuzzer_module.ini_entries = p;
memcpy(p, HARDCODED_INI, sizeof(HARDCODED_INI) - 1); memcpy(p, HARDCODED_INI, sizeof(HARDCODED_INI) - 1);
p += sizeof(HARDCODED_INI) - 1; p += sizeof(HARDCODED_INI) - 1;
if (extra_ini) { if (extra_ini) {
@ -234,7 +235,7 @@ int fuzzer_shutdown_php(void)
php_module_shutdown(); php_module_shutdown();
sapi_shutdown(); sapi_shutdown();
free(fuzzer_module.ini_entries); free((void *)fuzzer_module.ini_entries);
return SUCCESS; return SUCCESS;
} }