Skip to content

Commit

Permalink
ini_entries is read-only PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Sep 4, 2023
1 parent 21366ab commit 15df465
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions plugins/php/php_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct uwsgi_php {
char *fallback;
char *fallback2;
char *fallback_qs;
char *ini_entries;
size_t ini_size;
int dump_config;
char *server_software;
Expand Down Expand Up @@ -232,21 +233,31 @@ static sapi_module_struct uwsgi_sapi_module;

void uwsgi_php_append_config(char *filename) {
size_t file_size = 0;
char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL);
uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + file_size);
memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, file_content, file_size);
char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL);
if (uphp.ini_size) {
uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + file_size);
} else {
uphp.ini_entries = malloc(file_size);
}
memcpy(uphp.ini_entries + uphp.ini_size, file_content, file_size);
uphp.ini_size += file_size-1;
free(file_content);
uwsgi_sapi_module.ini_entries = uphp.ini_entries;
}

void uwsgi_php_set(char *opt) {

uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + strlen(opt)+2);
memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, opt, strlen(opt));
if (uphp.ini_size) {
uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + strlen(opt)+2);
} else {
uphp.ini_entries = malloc(strlen(opt)+2);
}
memcpy(uphp.ini_entries + uphp.ini_size, opt, strlen(opt));

uphp.ini_size += strlen(opt)+1;
uwsgi_sapi_module.ini_entries[uphp.ini_size-1] = '\n';
uwsgi_sapi_module.ini_entries[uphp.ini_size] = 0;
uphp.ini_entries[uphp.ini_size-1] = '\n';
uphp.ini_entries[uphp.ini_size] = 0;
uwsgi_sapi_module.ini_entries = uphp.ini_entries;
}

extern ps_module ps_mod_uwsgi;
Expand Down

0 comments on commit 15df465

Please sign in to comment.