[php-src] Issue #11139: BUG: PHP-Embed: php_embed_module.php_ini_path_override not properly processed.
| From: | ronpinkas | Date: | Thu, 27 Apr 2023 03:02:48 +0000 |
| Subject: | [php-src] Issue #11139: BUG: PHP-Embed: php_embed_module.php_ini_path_override not properly processed. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244280@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11139
Author: ronpinkas
### Description
The following self contained, reduced, code:
```
#include <stdio.h>
#include <sapi/embed/php_embed.h>
void cb_php( int argc, char **argv, const char *eval_string, const char *cPathINI ){
char sIniPath[ 1024 ];
if( cPathINI && strlen(cPathINI) > 0 ){
strcpy( sIniPath, cPathINI );
php_embed_module.php_ini_path_override = sIniPath;
printf( "INI: %s\n", php_embed_module.php_ini_path_override );
}
else{
php_embed_module.php_ini_path_override = NULL;
}
PHP_EMBED_START_BLOCK(argc, argv);
zend_eval_string((char *)eval_string, NULL, "embed_script");
PHP_EMBED_END_BLOCK();
}
void CreateFile( char *FileName, char *Content ){
FILE *file = fopen( FileName, "w" );
if (file == NULL){
printf("Error: Unable to create '%s' file!\n", FileName );
exit( 1 );
}
fprintf( file, "%s", Content );
fclose( file );
}
int main(int argc, char *argv[]){
#define IniName "myphp.ini"
#define ScriptName "check_settings.php"
char *sPHP = "<?php\n"
"// Check relevant PHP settings\n"
"$settings = [\n"
" 'max_input_time',\n"
" 'obscure_setting'\n" // Add the obscure setting here
"];\n"
"echo \"PHP Settings:\\n\";\n"
"foreach ($settings as $setting) {\n"
" echo $setting . ': ' . ini_get($setting) .
\"\\n\";\n"
"}\n"
"echo 'Loaded Configuration File: ' . php_ini_loaded_file() .
\"\\n\";\n"
"?>\n";
CreateFile( IniName, "max_input_time = 30\nobscure_setting = 12345\n" );
CreateFile( ScriptName, sPHP );
cb_php( argc, argv, "require( \"./" ScriptName "\" );",
"./"IniName );
return 0;
}
```
Resulted in this output:
```
INI: ./myphp.ini
PHP Settings:
max_input_time: 30
obscure_setting: 12345
Loaded Configuration File: /home/omie/dsv/omie-corevm/phpemb/myphp.ini
```
But I expected this output instead:
```
INI: ./myphp.ini
PHP Settings:
max_input_time: -1
obscure_setting:
Loaded Configuration File: /home/omie/dsv/omie-corevm/phpemb/myphp.ini
```
### PHP Version
PHP 8.1.16
### Operating System
Amazon Linux 2