Skip to content

Commit 5210949

Browse files
committed
Constify char* arguments of SAPIs
1 parent 4dd44bc commit 5210949

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

ext/filter/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval
360360
}
361361
/* }}} */
362362

363-
static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
363+
static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
364364
{
365365
zval new_var, raw_var;
366366
zval *array_ptr = NULL, *orig_array_ptr = NULL;

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_le
15101510

15111511
case 4: /* send to SAPI */
15121512
if (sapi_module.log_message) {
1513-
sapi_module.log_message((char *) message, -1);
1513+
sapi_module.log_message(message, -1);
15141514
} else {
15151515
return FAILURE;
15161516
}

main/SAPI.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) {
610610
}
611611
}
612612

613-
SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
613+
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
614614
{
615615
sapi_header_line ctr = {0};
616616
int r;
@@ -982,7 +982,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
982982
return SUCCESS;
983983
}
984984

985-
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
985+
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
986986
{
987987
if (SG(sapi_started) && EG(current_execute_data)) {
988988
return FAILURE;
@@ -1014,7 +1014,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void)
10141014
}
10151015
}
10161016

1017-
SAPI_API char *sapi_getenv(char *name, size_t name_len)
1017+
SAPI_API char *sapi_getenv(const char *name, size_t name_len)
10181018
{
10191019
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
10201020
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
@@ -1101,7 +1101,7 @@ SAPI_API void sapi_terminate_process(void) {
11011101
}
11021102
}
11031103

1104-
SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
1104+
SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, const char *val, unsigned int val_len, void *arg) /* {{{ */
11051105
{
11061106
zval *return_value = (zval*)arg;
11071107
char *str = NULL;

main/SAPI.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ SAPI_API void sapi_shutdown(void);
145145
SAPI_API void sapi_activate(void);
146146
SAPI_API void sapi_deactivate(void);
147147
SAPI_API void sapi_initialize_empty_request(void);
148-
SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
148+
SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, const char *val, unsigned int val_len, void *arg);
149149
END_EXTERN_C()
150150

151151
/*
@@ -160,7 +160,7 @@ END_EXTERN_C()
160160
*/
161161

162162
typedef struct {
163-
char *line; /* If you allocated this, you need to free it yourself */
163+
const char *line; /* If you allocated this, you need to free it yourself */
164164
size_t line_len;
165165
zend_long response_code; /* long due to zend_parse_parameters compatibility */
166166
} sapi_header_line;
@@ -177,7 +177,7 @@ BEGIN_EXTERN_C()
177177
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
178178

179179
/* Deprecated functions. Use sapi_header_op instead. */
180-
SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
180+
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
181181
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
182182

183183

@@ -190,11 +190,11 @@ SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry);
190190
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
191191
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void));
192192
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
193-
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
193+
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
194194

195195
SAPI_API int sapi_flush(void);
196196
SAPI_API zend_stat_t *sapi_get_stat(void);
197-
SAPI_API char *sapi_getenv(char *name, size_t name_len);
197+
SAPI_API char *sapi_getenv(const char *name, size_t name_len);
198198

199199
SAPI_API char *sapi_get_default_content_type(void);
200200
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header);
@@ -223,7 +223,7 @@ struct _sapi_module_struct {
223223
size_t (*ub_write)(const char *str, size_t str_length);
224224
void (*flush)(void *server_context);
225225
zend_stat_t *(*get_stat)(void);
226-
char *(*getenv)(char *name, size_t name_len);
226+
char *(*getenv)(const char *name, size_t name_len);
227227

228228
void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
229229

@@ -235,7 +235,7 @@ struct _sapi_module_struct {
235235
char *(*read_cookies)(void);
236236

237237
void (*register_server_variables)(zval *track_vars_array);
238-
void (*log_message)(char *message, int syslog_type_int);
238+
void (*log_message)(const char *message, int syslog_type_int);
239239
double (*get_request_time)(void);
240240
void (*terminate_process)(void);
241241

@@ -255,7 +255,7 @@ struct _sapi_module_struct {
255255
int (*get_target_uid)(uid_t *);
256256
int (*get_target_gid)(gid_t *);
257257

258-
unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
258+
unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
259259

260260
void (*ini_defaults)(HashTable *configuration_hash);
261261
int phpinfo_as_text;
@@ -288,7 +288,7 @@ struct _sapi_post_entry {
288288
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg)
289289

290290
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
291-
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len)
291+
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)
292292

293293
BEGIN_EXTERN_C()
294294
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);

main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys
877877
/* Otherwise fall back to the default logging location, if we have one */
878878

879879
if (sapi_module.log_message) {
880-
sapi_module.log_message((char *) log_message, syslog_type_int);
880+
sapi_module.log_message(log_message, syslog_type_int);
881881
}
882882
PG(in_error_log) = 0;
883883
}

sapi/apache2handler/sapi_apache2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ php_apache_sapi_read_cookies(void)
243243
}
244244

245245
static char *
246-
php_apache_sapi_getenv(char *name, size_t name_len)
246+
php_apache_sapi_getenv(const char *name, size_t name_len)
247247
{
248248
php_struct *ctx = SG(server_context);
249249
const char *env_var;
@@ -305,7 +305,7 @@ php_apache_sapi_flush(void *server_context)
305305
}
306306
}
307307

308-
static void php_apache_sapi_log_message(char *msg, int syslog_type_int)
308+
static void php_apache_sapi_log_message(const char *msg, int syslog_type_int)
309309
{
310310
php_struct *ctx;
311311
int aplog_type = APLOG_ERR;
@@ -354,7 +354,7 @@ static void php_apache_sapi_log_message(char *msg, int syslog_type_int)
354354
}
355355
}
356356

357-
static void php_apache_sapi_log_message_ex(char *msg, request_rec *r)
357+
static void php_apache_sapi_log_message_ex(const char *msg, request_rec *r)
358358
{
359359
if (r) {
360360
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, msg, r->filename);

sapi/cgi/cgi_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static char *cgi_getenv_win32(const char *name, size_t name_len)
553553
}
554554
#endif
555555

556-
static char *sapi_cgi_getenv(char *name, size_t name_len)
556+
static char *sapi_cgi_getenv(const char *name, size_t name_len)
557557
{
558558
#ifndef PHP_WIN32
559559
return getenv(name);
@@ -562,7 +562,7 @@ static char *sapi_cgi_getenv(char *name, size_t name_len)
562562
#endif
563563
}
564564

565-
static char *sapi_fcgi_getenv(char *name, size_t name_len)
565+
static char *sapi_fcgi_getenv(const char *name, size_t name_len)
566566
{
567567
/* when php is started by mod_fastcgi, no regular environment
568568
* is provided to PHP. It is always sent to PHP at the start
@@ -747,7 +747,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array)
747747
}
748748
}
749749

750-
static void sapi_cgi_log_message(char *message, int syslog_type_int)
750+
static void sapi_cgi_log_message(const char *message, int syslog_type_int)
751751
{
752752
if (fcgi_is_fastcgi() && CGIG(fcgi_logging)) {
753753
fcgi_request *request;

sapi/cli/php_cli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */
354354
}
355355
/* }}} */
356356

357-
static void sapi_cli_log_message(char *message, int syslog_type_int) /* {{{ */
357+
static void sapi_cli_log_message(const char *message, int syslog_type_int) /* {{{ */
358358
{
359359
fprintf(stderr, "%s\n", message);
360360
#ifdef PHP_WIN32

sapi/cli/php_cli_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */
777777
#endif
778778
} /* }}} */
779779

780-
static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */
780+
static void sapi_cli_server_log_message(const char *msg, int syslog_type_int) /* {{{ */
781781
{
782782
sapi_cli_server_log_write(PHP_CLI_SERVER_LOG_MESSAGE, msg);
783783
} /* }}} */

sapi/embed/php_embed.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ static void php_embed_send_header(sapi_header_struct *sapi_header, void *server_
9191
{
9292
}
9393

94-
static void php_embed_log_message(char *message, int syslog_type_int)
94+
static void php_embed_log_message(const char *message, int syslog_type_int)
9595
{
96-
fprintf (stderr, "%s\n", message);
96+
fprintf(stderr, "%s\n", message);
9797
}
9898

9999
static void php_embed_register_variables(zval *track_vars_array)

sapi/fpm/fpm/fpm_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int parent = 1;
107107
static int request_body_fd;
108108
static int fpm_is_running = 0;
109109

110-
static char *sapi_cgibin_getenv(char *name, size_t name_len);
110+
static char *sapi_cgibin_getenv(const char *name, size_t name_len);
111111
static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
112112

113113
#define PHP_MODE_STANDARD 1
@@ -464,7 +464,7 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes) /* {{{ */
464464
}
465465
/* }}} */
466466

467-
static char *sapi_cgibin_getenv(char *name, size_t name_len) /* {{{ */
467+
static char *sapi_cgibin_getenv(const char *name, size_t name_len) /* {{{ */
468468
{
469469
/* if fpm has started, use fcgi env */
470470
if (fpm_is_running) {
@@ -607,7 +607,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len)
607607

608608
/* {{{ sapi_cgi_log_message
609609
*/
610-
static void sapi_cgi_log_message(char *message, int syslog_type_int)
610+
static void sapi_cgi_log_message(const char *message, int syslog_type_int)
611611
{
612612
zlog_msg(ZLOG_NOTICE, "PHP message: ", message);
613613
}

sapi/fuzzer/fuzzer-sapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void register_variables(zval *track_vars_array)
7272
php_import_environment_variables(track_vars_array);
7373
}
7474

75-
static void log_message(char *message, int level)
75+
static void log_message(const char *message, int level)
7676
{
7777
}
7878

sapi/litespeed/lsapi_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int sapi_lsapi_deactivate(void)
191191

192192
/* {{{ sapi_lsapi_getenv
193193
*/
194-
static char *sapi_lsapi_getenv( char * name, size_t name_len )
194+
static char *sapi_lsapi_getenv(const char * name, size_t name_len )
195195
{
196196
if ( lsapi_mode ) {
197197
return LSAPI_GetEnv( name );
@@ -509,7 +509,7 @@ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers)
509509

510510
/* {{{ sapi_lsapi_send_headers
511511
*/
512-
static void sapi_lsapi_log_message(char *message, int syslog_type_int)
512+
static void sapi_lsapi_log_message(const char *message, int syslog_type_int)
513513
{
514514
char buf[8192];
515515
int len = strlen( message );
@@ -521,7 +521,7 @@ static void sapi_lsapi_log_message(char *message, int syslog_type_int)
521521
len = 8191;
522522
++len;
523523
}
524-
LSAPI_Write_Stderr( message, len);
524+
LSAPI_Write_Stderr( message, len );
525525
}
526526
/* }}} */
527527

sapi/phpdbg/phpdbg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ static void php_sapi_phpdbg_send_header(sapi_header_struct *sapi_header, void *s
772772
}
773773
/* }}} */
774774

775-
static void php_sapi_phpdbg_log_message(char *message, int syslog_type_int) /* {{{ */
775+
static void php_sapi_phpdbg_log_message(const char *message, int syslog_type_int) /* {{{ */
776776
{
777777
/*
778778
* We must not request TSRM before being booted

0 commit comments

Comments
 (0)