diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index 1074c6b2516..cd340035a27 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -116,7 +116,7 @@ TSRM_TLS uint8_t in_main_thread = 0; TSRM_TLS uint8_t is_thread_shutdown = 0; /* Startup TSRM (call once for the entire process) */ -TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename) +TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename) {/*{{{*/ #ifdef TSRM_WIN32 tls_key = TlsAlloc(); @@ -698,7 +698,7 @@ int tsrm_error(int level, const char *format, ...) #endif -void tsrm_error_set(int level, char *debug_filename) +void tsrm_error_set(int level, const char *debug_filename) {/*{{{*/ tsrm_error_level = level; diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 661c8732929..6978b497320 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -79,7 +79,7 @@ extern "C" { #endif /* startup/shutdown */ -TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename); +TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename); TSRM_API void tsrm_shutdown(void); /* environ lock API */ @@ -115,7 +115,7 @@ typedef void (*tsrm_shutdown_func_t)(void); TSRM_API int tsrm_error(int level, const char *format, ...); -TSRM_API void tsrm_error_set(int level, char *debug_filename); +TSRM_API void tsrm_error_set(int level, const char *debug_filename); /* utility functions */ TSRM_API THREAD_T tsrm_thread_id(void); diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 15659ba5464..23cb31c2fe9 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -443,7 +443,7 @@ TSRM_API FILE *popen(const char *command, const char *type) return popen_ex(command, type, NULL, NULL); }/*}}}*/ -TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env) +TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env) {/*{{{*/ FILE *stream = NULL; int fno, type_len, read, mode; diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index e002032218e..0f5c003abd0 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -94,7 +94,7 @@ const char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_l TSRM_API void tsrm_win32_startup(void); TSRM_API void tsrm_win32_shutdown(void); -TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env); +TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env); TSRM_API FILE *popen(const char *command, const char *type); TSRM_API int pclose(FILE *stream); TSRM_API int tsrm_win32_access(const char *pathname, int mode); diff --git a/Zend/zend.c b/Zend/zend.c index 8a2bbf35dd1..fd535325371 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -78,7 +78,7 @@ ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data); ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap); void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); -ZEND_API char *(*zend_getenv)(char *name, size_t name_len); +ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); ZEND_API int (*zend_post_startup_cb)(void) = NULL; ZEND_API void (*zend_post_shutdown_cb)(void) = NULL; diff --git a/Zend/zend.h b/Zend/zend.h index 939d3e3e349..997f2e70536 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -198,7 +198,7 @@ typedef struct _zend_utility_functions { int (*stream_open_function)(const char *filename, zend_file_handle *handle); void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap); void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap); - char *(*getenv_function)(char *name, size_t name_len); + char *(*getenv_function)(const char *name, size_t name_len); zend_string *(*resolve_path_function)(const char *filename, size_t filename_len); } zend_utility_functions; @@ -286,7 +286,7 @@ extern ZEND_API void (*zend_on_timeout)(int seconds); extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle); extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap); extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap); -extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len); +extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len); extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len); /* These two callbacks are especially for opcache */ diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 82c5fbdf7ca..56506c55a89 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2716,7 +2716,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_lengt /* Disabled functions support */ -ZEND_API int zend_disable_function(char *function_name, size_t function_name_length) /* {{{ */ +ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ { return zend_hash_str_del(CG(function_table), function_name, function_name_length); } @@ -2753,7 +2753,7 @@ static const zend_function_entry disabled_class_new[] = { ZEND_FE_END }; -ZEND_API int zend_disable_class(char *class_name, size_t class_name_length) /* {{{ */ +ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ { zend_class_entry *disabled_class; zend_string *key; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index d7e5e528a09..9a34ab050d0 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -334,8 +334,8 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen #define zend_register_ns_class_alias(ns, name, ce) \ zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1) -ZEND_API int zend_disable_function(char *function_name, size_t function_name_length); -ZEND_API int zend_disable_class(char *class_name, size_t class_name_length); +ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length); +ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length); ZEND_API ZEND_COLD void zend_wrong_param_count(void); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 86e169893ab..6d3c12b0f06 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1720,7 +1720,7 @@ void zend_do_extended_fcall_end(void) /* {{{ */ } /* }}} */ -zend_bool zend_is_auto_global_str(char *name, size_t len) /* {{{ */ { +zend_bool zend_is_auto_global_str(const char *name, size_t len) /* {{{ */ { zend_auto_global *auto_global; if ((auto_global = zend_hash_str_find_ptr(CG(auto_globals), name, len)) != NULL) { diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 9a1e5adaafe..9c6070d8889 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -844,7 +844,7 @@ typedef struct _zend_auto_global { ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); ZEND_API void zend_activate_auto_globals(void); ZEND_API zend_bool zend_is_auto_global(zend_string *name); -ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len); +ZEND_API zend_bool zend_is_auto_global_str(const char *name, size_t len); ZEND_API size_t zend_dirname(char *path, size_t len); ZEND_API void zend_set_function_arg_flags(zend_function *func); diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c index 665773b1200..7eda51b73be 100644 --- a/ext/com_dotnet/com_olechar.c +++ b/ext/com_dotnet/com_olechar.c @@ -26,7 +26,7 @@ #include "php_com_dotnet_internal.h" -PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t string_len, int codepage) +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage) { OLECHAR *olestring = NULL; DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS; diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c index acd2e3d5129..ffd2400f751 100644 --- a/ext/com_dotnet/com_typeinfo.c +++ b/ext/com_dotnet/com_typeinfo.c @@ -260,7 +260,7 @@ ITypeLib *php_com_cache_typelib(ITypeLib* TL, char *cache_key, zend_long cache_k return result; } -PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string, int codepage, int *cached) { ITypeLib *TL; diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index 8521277083f..4974bb78e3c 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -82,7 +82,7 @@ int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index /* com_olechar.c */ PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring, size_t *string_len, int codepage); -PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage); @@ -130,7 +130,7 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1); /* com_typeinfo.c */ -PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string, int codepage, int *cached); PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage); PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 51c56afb3c5..a908fed2c7a 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -617,7 +617,7 @@ static const char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib /* }}} */ /* {{{ date_format - (gm)date helper */ -static zend_string *date_format(char *format, size_t format_len, timelib_time *t, int localtime) +static zend_string *date_format(const char *format, size_t format_len, timelib_time *t, int localtime) { smart_str string = {0}; size_t i; @@ -798,7 +798,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) } /* }}} */ -PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime) /* {{{ */ +PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime) /* {{{ */ { timelib_time *t; timelib_tzinfo *tzi; @@ -982,14 +982,14 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb) /* }}} */ /* {{{ php_parse_date: Backwards compatibility function */ -PHPAPI zend_long php_parse_date(char *string, zend_long *now) +PHPAPI zend_long php_parse_date(const char *string, zend_long *now) { timelib_time *parsed_time; timelib_error_container *error = NULL; int error2; zend_long retval; - parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); + parsed_time = timelib_strtotime((char *) string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (error->error_count) { timelib_time_dtor(parsed_time); timelib_error_container_dtor(error); @@ -2187,7 +2187,7 @@ static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *us #endif } -PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor) /* {{{ */ +PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor) /* {{{ */ { timelib_time *now; timelib_tzinfo *tzi = NULL; @@ -2202,9 +2202,18 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, timelib_time_dtor(dateobj->time); } if (format) { - dateobj->time = timelib_parse_from_format(format, time_str_len ? time_str : "", time_str_len ? time_str_len : 0, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); + if (time_str_len == 0) { + time_str = ""; + } + // TODO: drop this const casts + dateobj->time = timelib_parse_from_format((char *) format, (char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); } else { - dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); + if (time_str_len == 0) { + time_str = "now"; + time_str_len = sizeof("now") - 1; + } + // TODO: drop this const casts + dateobj->time = timelib_strtotime((char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); } /* update last errors and warnings */ diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 1ab7b3ccd97..b89438e0c56 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -108,14 +108,14 @@ ZEND_END_MODULE_GLOBALS(date) PHPAPI time_t php_time(void); /* Backwards compatibility wrapper */ -PHPAPI zend_long php_parse_date(char *string, zend_long *now); +PHPAPI zend_long php_parse_date(const char *string, zend_long *now); PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt); PHPAPI int php_idate(char format, time_t ts, int localtime); #define _php_strftime php_strftime PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm); -PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime); +PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime); /* Mechanism to set new TZ database */ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb); @@ -131,7 +131,7 @@ PHPAPI zend_class_entry *php_date_get_period_ce(void); /* Functions for creating DateTime objects, and initializing them from a string */ PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object); -PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor); +PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor); #endif /* PHP_DATE_H */ diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 8feae0a3dfa..0e01c30097e 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -75,7 +75,7 @@ static const filter_list_entry filter_list[] = { #define PARSE_SESSION 6 #endif -static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len); +static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len); static unsigned int php_sapi_filter_init(void); /* {{{ filter_module_entry @@ -360,7 +360,7 @@ handle_default: } /* }}} */ -static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */ +static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */ { zval new_var, raw_var; zval *array_ptr = NULL, *orig_array_ptr = NULL; diff --git a/ext/json/json.c b/ext/json/json.c index 68990f5ca41..1797c00c9c9 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -195,7 +195,7 @@ static const char *php_json_get_error_msg(php_json_error_code error_code) /* {{{ } /* }}} */ -PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */ +PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */ { php_json_parser parser; diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y index 4705e498a61..8802d18439d 100644 --- a/ext/json/json_parser.y +++ b/ext/json/json_parser.y @@ -301,7 +301,7 @@ static const php_json_parser_methods default_parser_methods = PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser, zval *return_value, - char *str, + const char *str, size_t str_len, int options, int max_depth, @@ -317,7 +317,7 @@ PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser, PHP_JSON_API void php_json_parser_init(php_json_parser *parser, zval *return_value, - char *str, + const char *str, size_t str_len, int options, int max_depth) diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re index 5b571e6dd2d..03ccdde58b5 100644 --- a/ext/json/json_scanner.re +++ b/ext/json/json_scanner.re @@ -91,7 +91,7 @@ static int php_json_ucs2_to_int(php_json_scanner *s, int size) return php_json_ucs2_to_int_ex(s, size, 1); } -void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options) +void php_json_scanner_init(php_json_scanner *s, const char *str, size_t str_len, int options) { s->cursor = (php_json_ctype *) str; s->limit = (php_json_ctype *) str + str_len; diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 4fc7ded7d4f..ee8affa1d1c 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -98,9 +98,9 @@ ZEND_TSRMLS_CACHE_EXTERN() PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth); PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options); -PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth); +PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth); -static inline int php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth) +static inline int php_json_decode(zval *return_value, const char *str, int str_len, zend_bool assoc, zend_long depth) { return php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth); } diff --git a/ext/json/php_json_parser.h b/ext/json/php_json_parser.h index 05f7a061c62..dc0453f4fa9 100644 --- a/ext/json/php_json_parser.h +++ b/ext/json/php_json_parser.h @@ -61,7 +61,7 @@ struct _php_json_parser { PHP_JSON_API void php_json_parser_init_ex( php_json_parser *parser, zval *return_value, - char *str, + const char *str, size_t str_len, int options, int max_depth, @@ -70,7 +70,7 @@ PHP_JSON_API void php_json_parser_init_ex( PHP_JSON_API void php_json_parser_init( php_json_parser *parser, zval *return_value, - char *str, + const char *str, size_t str_len, int options, int max_depth); diff --git a/ext/json/php_json_scanner.h b/ext/json/php_json_scanner.h index 7a2d841703a..e5a4979591c 100644 --- a/ext/json/php_json_scanner.h +++ b/ext/json/php_json_scanner.h @@ -40,7 +40,7 @@ typedef struct _php_json_scanner { } php_json_scanner; -void php_json_scanner_init(php_json_scanner *scanner, char *str, size_t str_len, int options); +void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options); int php_json_scan(php_json_scanner *s); #endif /* PHP_JSON_SCANNER_H */ diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index ef8f39f7a9a..aa81410c82f 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4798,7 +4798,7 @@ static int accel_finish_startup(void) int (*orig_header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers) = sapi_module.header_handler; int (*orig_send_headers)(sapi_headers_struct *sapi_headers) = sapi_module.send_headers; void (*orig_send_header)(sapi_header_struct *sapi_header, void *server_context)= sapi_module.send_header; - char *(*orig_getenv)(char *name, size_t name_len) = sapi_module.getenv; + char *(*orig_getenv)(const char *name, size_t name_len) = sapi_module.getenv; size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write; void (*orig_flush)(void *server_context) = sapi_module.flush; uint32_t orig_compiler_options = CG(compiler_options); diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 1a0ec6719fd..b2c5cefc701 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -6888,7 +6888,7 @@ static void php_openssl_load_cipher_mode(struct php_openssl_cipher_mode *mode, c } /* }}} */ -static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_required_len, +static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_required_len, zend_bool *free_iv, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode) /* {{{ */ { char *iv_new; @@ -6942,9 +6942,9 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode, - char **ppassword, size_t *ppassword_len, zend_bool *free_password, - char **piv, size_t *piv_len, zend_bool *free_iv, - char *tag, int tag_len, zend_long options, int enc) /* {{{ */ + const char **ppassword, size_t *ppassword_len, zend_bool *free_password, + const char **piv, size_t *piv_len, zend_bool *free_iv, + const char *tag, int tag_len, zend_long options, int enc) /* {{{ */ { unsigned char *key; int key_len, password_len; @@ -7014,8 +7014,8 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type, static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode, - zend_string **poutbuf, int *poutlen, char *data, size_t data_len, - char *aad, size_t aad_len, int enc) /* {{{ */ + zend_string **poutbuf, int *poutlen, const char *data, size_t data_len, + const char *aad, size_t aad_len, int enc) /* {{{ */ { int i = 0; @@ -7025,7 +7025,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type, return FAILURE; } - if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (unsigned char *)aad, (int)aad_len)) { + if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (const unsigned char *) aad, (int) aad_len)) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "Setting of additional application data failed"); return FAILURE; @@ -7034,7 +7034,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type, *poutbuf = zend_string_alloc((int)data_len + EVP_CIPHER_block_size(cipher_type), 0); if (!EVP_CipherUpdate(cipher_ctx, (unsigned char*)ZSTR_VAL(*poutbuf), - &i, (unsigned char *)data, (int)data_len)) { + &i, (const unsigned char *)data, (int)data_len)) { /* we don't show warning when we fail but if we ever do, then it should look like this: if (mode->is_single_run_aead && !enc) { php_error_docref(NULL, E_WARNING, "Tag verifycation failed"); @@ -7054,7 +7054,14 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type, /* }}} */ -PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, zval *tag, zend_long tag_len, char *aad, size_t aad_len) +PHP_OPENSSL_API zend_string* php_openssl_encrypt( + const char *data, size_t data_len, + const char *method, size_t method_len, + const char *password, size_t password_len, + zend_long options, + const char *iv, size_t iv_len, + zval *tag, zend_long tag_len, + const char *aad, size_t aad_len) { const EVP_CIPHER *cipher_type; EVP_CIPHER_CTX *cipher_ctx; @@ -7130,10 +7137,10 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, ch } if (free_password) { - efree(password); + efree((void *) password); } if (free_iv) { - efree(iv); + efree((void *) iv); } EVP_CIPHER_CTX_reset(cipher_ctx); EVP_CIPHER_CTX_free(cipher_ctx); @@ -7163,7 +7170,14 @@ PHP_FUNCTION(openssl_encrypt) } /* }}} */ -PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, char *tag, zend_long tag_len, char *aad, size_t aad_len) +PHP_OPENSSL_API zend_string* php_openssl_decrypt( + const char *data, size_t data_len, + const char *method, size_t method_len, + const char *password, size_t password_len, + zend_long options, + const char *iv, size_t iv_len, + const char *tag, zend_long tag_len, + const char *aad, size_t aad_len) { const EVP_CIPHER *cipher_type; EVP_CIPHER_CTX *cipher_ctx; @@ -7222,10 +7236,10 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, ch } if (free_password) { - efree(password); + efree((void *) password); } if (free_iv) { - efree(iv); + efree((void *) iv); } if (base64_str) { zend_string_release_ex(base64_str, 0); @@ -7262,7 +7276,7 @@ PHP_FUNCTION(openssl_decrypt) } /* }}} */ -PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method) +PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method) { const EVP_CIPHER *cipher_type; diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index f786772f589..0ae0f9698cf 100644 --- a/ext/openssl/php_openssl.h +++ b/ext/openssl/php_openssl.h @@ -92,16 +92,24 @@ php_stream_transport_factory_func php_openssl_ssl_socket_factory; void php_openssl_store_errors(); -PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method); +PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method); PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long length); -PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, - char *method, size_t method_len, char *password, - size_t password_len, zend_long options, char *iv, size_t iv_len, - zval *tag, zend_long tag_len, char *aad, size_t add_len); -PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, - char *method, size_t method_len, char *password, - size_t password_len, zend_long options, char *iv, size_t iv_len, - char *tag, zend_long tag_len, char *aad, size_t add_len); +PHP_OPENSSL_API zend_string* php_openssl_encrypt( + const char *data, size_t data_len, + const char *method, size_t method_len, + const char *password, size_t password_len, + zend_long options, + const char *iv, size_t iv_len, + zval *tag, zend_long tag_len, + const char *aad, size_t aad_len); +PHP_OPENSSL_API zend_string* php_openssl_decrypt( + const char *data, size_t data_len, + const char *method, size_t method_len, + const char *password, size_t password_len, + zend_long options, + const char *iv, size_t iv_len, + const char *tag, zend_long tag_len, + const char *aad, size_t aad_len); PHP_MINIT_FUNCTION(openssl); PHP_MSHUTDOWN_FUNCTION(openssl); diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 9f67bff14cc..55f9d2db7ba 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -555,12 +555,12 @@ static zend_string **make_subpats_table(uint32_t num_subpats, pcre_cache_entry * /* {{{ static calculate_unit_length */ /* Calculates the byte length of the next character. Assumes valid UTF-8 for PCRE2_UTF. */ -static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, char *start) +static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, const char *start) { size_t unit_len; if (pce->compile_options & PCRE2_UTF) { - char *end = start; + const char *end = start; /* skip continuation bytes */ while ((*++end & 0xC0) == 0x80); @@ -1038,7 +1038,7 @@ static inline void add_offset_pair( /* }}} */ static void populate_subpat_array( - zval *subpats, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, + zval *subpats, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) { zend_bool offset_capture = (flags & PREG_OFFSET_CAPTURE) != 0; zend_bool unmatched_as_null = (flags & PREG_UNMATCHED_AS_NULL) != 0; @@ -1531,7 +1531,7 @@ static int preg_get_backref(char **str, int *backref) /* {{{ preg_do_repl_func */ -static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) +static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) { zend_string *result_str; zval retval; /* Function return value */ @@ -1570,7 +1570,7 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach */ PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, - char *subject, size_t subject_len, + const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count) { @@ -1596,7 +1596,7 @@ PHPAPI zend_string *php_pcre_replace(zend_string *regex, /* }}} */ /* {{{ php_pcre_replace_impl() */ -PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count) +PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count) { uint32_t options; /* Execution options */ int count; /* Count of matched subpatterns */ @@ -1610,10 +1610,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su size_t last_end_offset; /* Where the last search ended */ char *walkbuf, /* Location of current replacement in the result */ *walk, /* Used to walk the replacement string */ - *match, /* The current match */ - *piece, /* The current piece of subject */ - *replace_end, /* End of replacement string */ walk_last; /* Last walked character */ + const char *match, /* The current match */ + *piece, /* The current piece of subject */ + *replace_end; /* End of replacement string */ size_t result_len; /* Length of result */ zend_string *result; /* Result of replacement */ pcre2_match_data *match_data; @@ -1838,7 +1838,7 @@ error: /* }}} */ /* {{{ php_pcre_replace_func_impl() */ -static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags) +static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags) { uint32_t options; /* Execution options */ int count; /* Count of matched subpatterns */ @@ -1849,7 +1849,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin size_t alloc_len; /* Actual allocated length */ PCRE2_SIZE start_offset; /* Where the new search starts */ size_t last_end_offset; /* Where the last search ended */ - char *match, /* The current match */ + const char *match, /* The current match */ *piece; /* The current piece of subject */ size_t result_len; /* Length of result */ zend_string *result; /* Result of replacement */ diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h index 4666f11b78e..808b671bb8f 100644 --- a/ext/pcre/php_pcre.h +++ b/ext/pcre/php_pcre.h @@ -25,7 +25,7 @@ #include -PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count); +PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count); PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count); PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions); @@ -53,7 +53,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset); -PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, +PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count); PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index 31da8ffdf99..ee0ce7168d3 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -36,12 +36,12 @@ #define YYFILL(n) { RET(PDO_PARSER_EOI); } typedef struct Scanner { - char *ptr, *cur, *tok, *end; + const char *ptr, *cur, *tok, *end; } Scanner; static int scan(Scanner *s) { - char *cursor = s->cur; + const char *cursor = s->cur; s->tok = cursor; /*!re2c @@ -68,9 +68,9 @@ static int scan(Scanner *s) } struct placeholder { - char *pos; + const char *pos; size_t len; - size_t qlen; /* quoted length of value */ + size_t qlen; /* quoted length of value */ char *quoted; /* quoted value */ int freeq; int bindno; @@ -81,11 +81,12 @@ static void free_param_name(zval *el) { efree(Z_PTR_P(el)); } -PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len, +PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len, char **outquery, size_t *outquery_len) { Scanner s; - char *ptr, *newbuffer; + const char *ptr; + char *newbuffer; ptrdiff_t t; uint32_t bindno = 0; int ret = 0, escapes = 0; diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index 7f4861db207..2fd3b00e999 100644 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -677,7 +677,7 @@ PDO_API int php_pdo_parse_data_source(const char *data_source, PDO_API zend_class_entry *php_pdo_get_dbh_ce(void); PDO_API zend_class_entry *php_pdo_get_exception(void); -PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len, +PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len, char **outquery, size_t *outquery_len); PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index d67c4dee47a..351d342c53a 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -168,12 +168,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char case PHAR_MIME_OTHER: /* send headers, output file contents */ efree(basename); - ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type); + ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-type: %s", mime_type); sapi_header_op(SAPI_HEADER_REPLACE, &ctr); - efree(ctr.line); - ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize); + efree((void *) ctr.line); + ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize); sapi_header_op(SAPI_HEADER_REPLACE, &ctr); - efree(ctr.line); + efree((void *) ctr.line); if (FAILURE == sapi_send_headers()) { zend_bailout(); @@ -790,9 +790,9 @@ PHP_METHOD(Phar, webPhar) ctr.response_code = 0; if (path_info[strlen(path_info)-1] == '/') { - ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1); + ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry + 1); } else { - ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry); + ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry); } if (not_cgi) { @@ -805,7 +805,7 @@ PHP_METHOD(Phar, webPhar) sapi_header_op(SAPI_HEADER_REPLACE, &ctr); sapi_send_headers(); - efree(ctr.line); + efree((void *) ctr.line); zend_bailout(); } } diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 6f966440248..73f8bf31c8d 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -247,7 +247,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS); PHPAPI int php_session_validate_sid(PS_VALIDATE_SID_ARGS); PHPAPI int php_session_update_timestamp(PS_UPDATE_TIMESTAMP_ARGS); -PHPAPI void session_adapt_url(const char *, size_t, char **, size_t *); +PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len); PHPAPI int php_session_destroy(void); PHPAPI void php_add_session_var(zend_string *name); @@ -260,12 +260,11 @@ PHPAPI int php_session_register_serializer(const char *name, zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS), int (*decode)(PS_SERIALIZER_DECODE_ARGS)); -PHPAPI void php_session_set_id(char *id); PHPAPI int php_session_start(void); PHPAPI int php_session_flush(int write); -PHPAPI const ps_module *_php_find_ps_module(char *name); -PHPAPI const ps_serializer *_php_find_ps_serializer(char *name); +PHPAPI const ps_module *_php_find_ps_module(const char *name); +PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name); PHPAPI int php_session_valid_key(const char *key); PHPAPI int php_session_reset_id(void); diff --git a/ext/session/session.c b/ext/session/session.c index 993f6a063f5..418a89d8839 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1374,7 +1374,7 @@ static int php_session_send_cookie(void) /* {{{ */ } /* }}} */ -PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */ +PHPAPI const ps_module *_php_find_ps_module(const char *name) /* {{{ */ { const ps_module *ret = NULL; const ps_module **mod; @@ -1390,7 +1390,7 @@ PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */ } /* }}} */ -PHPAPI const ps_serializer *_php_find_ps_serializer(char *name) /* {{{ */ +PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) /* {{{ */ { const ps_serializer *ret = NULL; const ps_serializer *mod; @@ -1648,10 +1648,10 @@ static int php_session_reset(void) /* {{{ */ /* This API is not used by any PHP modules including session currently. session_adapt_url() may be used to set Session ID to target url without starting "URL-Rewriter" output handler. */ -PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newlen) /* {{{ */ +PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len) /* {{{ */ { if (APPLY_TRANS_SID && (PS(session_status) == php_session_active)) { - *new = php_url_scanner_adapt_single_url(url, urllen, PS(session_name), ZSTR_VAL(PS(id)), newlen, 1); + *new_url = php_url_scanner_adapt_single_url(url, url_len, PS(session_name), ZSTR_VAL(PS(id)), new_len, 1); } } /* }}} */ diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 090f11e0abd..883b5d45c51 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1472,13 +1472,13 @@ PHP_FUNCTION(error_log) /* }}} */ /* For BC (not binary-safe!) */ -PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers) /* {{{ */ +PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers) /* {{{ */ { return _php_error_log_ex(opt_err, message, (opt_err == 3) ? strlen(message) : 0, opt, headers); } /* }}} */ -PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers) /* {{{ */ +PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers) /* {{{ */ { php_stream *stream = NULL; size_t nbytes; @@ -1870,7 +1870,7 @@ PHP_FUNCTION(register_shutdown_function) } /* }}} */ -PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */ +PHPAPI zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */ { if (!BG(user_shutdown_function_names)) { ALLOC_HASHTABLE(BG(user_shutdown_function_names)); @@ -1882,7 +1882,7 @@ PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t fun } /* }}} */ -PHPAPI zend_bool remove_user_shutdown_function(char *function_name, size_t function_len) /* {{{ */ +PHPAPI zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len) /* {{{ */ { if (BG(user_shutdown_function_names)) { return zend_hash_str_del(BG(user_shutdown_function_names), function_name, function_len) != FAILURE; diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 147bc1dd3a4..00727668dce 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -47,8 +47,8 @@ PHP_RSHUTDOWN_FUNCTION(user_filters); PHP_RSHUTDOWN_FUNCTION(browscap); /* Left for BC (not binary safe!) */ -PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers); -PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers); +PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers); +PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers); PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, zend_bool add_underscore); #define MT_N (624) @@ -150,8 +150,8 @@ typedef struct _php_shutdown_function_entry { int arg_count; } php_shutdown_function_entry; -PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry); -PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len); +PHPAPI extern zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry); +PHPAPI extern zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len); PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry); PHPAPI void php_call_shutdown_functions(void); diff --git a/ext/standard/dl.c b/ext/standard/dl.c index ed387761a84..f70ab6fbb59 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -70,7 +70,7 @@ PHPAPI PHP_FUNCTION(dl) /* {{{ php_load_shlib */ -PHPAPI void *php_load_shlib(char *path, char **errp) +PHPAPI void *php_load_shlib(const char *path, char **errp) { void *handle; char *err; @@ -98,7 +98,7 @@ PHPAPI void *php_load_shlib(char *path, char **errp) /* {{{ php_load_extension */ -PHPAPI int php_load_extension(char *filename, int type, int start_now) +PHPAPI int php_load_extension(const char *filename, int type, int start_now) { void *handle; char *libpath; @@ -243,35 +243,47 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now) } /* }}} */ +#else + +static void php_dl_error(const char *filename) +{ + php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", filename); +} + +PHPAPI void *php_load_shlib(const char *path, char **errp) +{ + php_dl_error(filename); + (*errp) = estrdup("No DL support"); +} + +PHPAPI int php_load_extension(const char *filename, int type, int start_now) +{ + php_dl_error(filename); + + return FAILURE; +} + +#endif + /* {{{ php_dl */ -PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now) +PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now) { - /* Load extension */ - if (php_load_extension(file, type, start_now) == FAILURE) { - RETVAL_FALSE; - } else { - RETVAL_TRUE; - } + /* Load extension */ + if (php_load_extension(file, type, start_now) == FAILURE) { + RETVAL_FALSE; + } else { + RETVAL_TRUE; + } } /* }}} */ PHP_MINFO_FUNCTION(dl) { - php_info_print_table_row(2, "Dynamic Library Support", "enabled"); -} - +#if defined(HAVE_LIBDL) +#define PHP_DL_SUPPORT_STATUS "enabled" #else - -PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now) -{ - php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", file); - RETVAL_FALSE; -} - -PHP_MINFO_FUNCTION(dl) -{ - PUTS("Dynamic Library support not available
.\n"); -} - +#define PHP_DL_SUPPORT_STATUS "unavailable" #endif + php_info_print_table_row(2, "Dynamic Library Support", PHP_DL_SUPPORT_STATUS); +} diff --git a/ext/standard/dl.h b/ext/standard/dl.h index d51df044d28..9d13b97ff72 100644 --- a/ext/standard/dl.h +++ b/ext/standard/dl.h @@ -19,9 +19,9 @@ #ifndef DL_H #define DL_H -PHPAPI int php_load_extension(char *filename, int type, int start_now); -PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now); -PHPAPI void *php_load_shlib(char *path, char **errp); +PHPAPI int php_load_extension(const char *filename, int type, int start_now); +PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now); +PHPAPI void *php_load_shlib(const char *path, char **errp); /* dynamic loading functions */ PHPAPI PHP_FUNCTION(dl); diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 9935e2b34c8..8ba205a9ed5 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -111,7 +111,7 @@ static size_t handle_line(int type, zval *array, char *buf, size_t bufl) { * If type==3, output will be printed binary, no lines will be saved or returned (passthru) * */ -PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value) +PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value) { FILE *fp; char *buf; @@ -282,7 +282,7 @@ PHP_FUNCTION(passthru) *NOT* safe for binary strings */ -PHPAPI zend_string *php_escape_shell_cmd(char *str) +PHPAPI zend_string *php_escape_shell_cmd(const char *str) { register size_t x, y; size_t l = strlen(str); @@ -389,7 +389,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) /* {{{ php_escape_shell_arg */ -PHPAPI zend_string *php_escape_shell_arg(char *str) +PHPAPI zend_string *php_escape_shell_arg(const char *str) { size_t x, y = 0; size_t l = strlen(str); diff --git a/ext/standard/exec.h b/ext/standard/exec.h index 97edbd099a2..6ad9ee0b405 100644 --- a/ext/standard/exec.h +++ b/ext/standard/exec.h @@ -20,8 +20,8 @@ PHP_MINIT_FUNCTION(proc_open); PHP_MINIT_FUNCTION(exec); -PHPAPI zend_string *php_escape_shell_cmd(char *); -PHPAPI zend_string *php_escape_shell_arg(char *); -PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value); +PHPAPI zend_string *php_escape_shell_cmd(const char *str); +PHPAPI zend_string *php_escape_shell_arg(const char *str); +PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value); #endif /* EXEC_H */ diff --git a/ext/standard/head.c b/ext/standard/head.c index 657510de5b2..06496f04aa3 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -34,15 +34,17 @@ PHP_FUNCTION(header) { zend_bool rep = 1; sapi_header_line ctr = {0}; + char *line; size_t len; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STRING(ctr.line, len) + Z_PARAM_STRING(line, len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(rep) Z_PARAM_LONG(ctr.response_code) ZEND_PARSE_PARAMETERS_END(); + ctr.line = line; ctr.line_len = (uint32_t)len; sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr); } @@ -53,13 +55,15 @@ PHP_FUNCTION(header) PHP_FUNCTION(header_remove) { sapi_header_line ctr = {0}; + char *line = NULL; size_t len = 0; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STRING(ctr.line, len) + Z_PARAM_STRING(line, len) ZEND_PARSE_PARAMETERS_END(); + ctr.line = line; ctr.line_len = (uint32_t)len; sapi_header_op(ZEND_NUM_ARGS() == 0 ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr); } diff --git a/ext/standard/html.c b/ext/standard/html.c index e1a0799375c..8e5b65d80c6 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -367,7 +367,7 @@ static inline unsigned int get_next_char( /* {{{ entity_charset determine_charset * Returns the charset identifier based on an explicitly provided charset, * the internal_encoding and default_charset ini settings, or UTF-8 by default. */ -static enum entity_charset determine_charset(char *charset_hint, zend_bool quiet) +static enum entity_charset determine_charset(const char *charset_hint, zend_bool quiet) { if (!charset_hint || !*charset_hint) { charset_hint = get_default_charset(); @@ -979,7 +979,7 @@ static entity_table_opt determine_entity_table(int all, int doctype) * only the basic ones, i.e., those in basic_entities_ex + the numeric entities * that correspond to quotes. */ -PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset) +PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset) { zend_string *ret; enum entity_charset charset; @@ -1015,7 +1015,7 @@ PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int fl } /* }}} */ -PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset) +PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset) { return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, 1, /* quiet */ 0); } @@ -1103,7 +1103,7 @@ static inline void find_entity_for_char_basic( /* {{{ php_escape_html_entities */ -PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet) +PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet) { size_t cursor, maxlen, len; zend_string *replaced; diff --git a/ext/standard/html.h b/ext/standard/html.h index 818ee1a0ca8..3aee85cd87f 100644 --- a/ext/standard/html.h +++ b/ext/standard/html.h @@ -44,9 +44,9 @@ void register_html_constants(INIT_FUNC_ARGS); -PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset); -PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet); -PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset); +PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset); +PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet); +PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset); PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, int *status); #endif /* HTML_H */ diff --git a/ext/standard/http.c b/ext/standard/http.c index 4b6866d3f82..386a0df1eb3 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -25,7 +25,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, size_t num_prefix_len, const char *key_prefix, size_t key_prefix_len, const char *key_suffix, size_t key_suffix_len, - zval *type, char *arg_sep, int enc_type) + zval *type, const char *arg_sep, int enc_type) { zend_string *key = NULL; char *newprefix, *p; diff --git a/ext/standard/image.c b/ext/standard/image.c index e967aaeee0d..147a146e5c2 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1293,7 +1293,7 @@ PHP_FUNCTION(image_type_to_extension) /* {{{ php_imagetype detect filetype from first bytes */ -PHPAPI int php_getimagetype(php_stream * stream, char *input, char *filetype) +PHPAPI int php_getimagetype(php_stream * stream, const char *input, char *filetype) { char tmp[12]; int twelve_bytes_read; diff --git a/ext/standard/info.c b/ext/standard/info.c index 8a090d20e53..262e95ae273 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -57,7 +57,7 @@ static ZEND_COLD int php_info_print_html_esc(const char *str, size_t len) /* {{{ size_t written; zend_string *new_str; - new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8"); + new_str = php_escape_html_entities((const unsigned char *) str, len, 0, ENT_QUOTES, "utf-8"); written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str)); zend_string_free(new_str); return written; @@ -249,9 +249,9 @@ PHPAPI ZEND_COLD void ZEND_COLD php_info_print_style(void) /* {{{ php_info_html_esc */ -PHPAPI ZEND_COLD zend_string *php_info_html_esc(char *string) +PHPAPI ZEND_COLD zend_string *php_info_html_esc(const char *string) { - return php_escape_html_entities((unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL); + return php_escape_html_entities((const unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL); } /* }}} */ @@ -1095,7 +1095,7 @@ PHPAPI ZEND_COLD void php_info_print_hr(void) /* {{{ */ } /* }}} */ -PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */ +PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, const char *header) /* {{{ */ { int spaces; diff --git a/ext/standard/info.h b/ext/standard/info.h index 95eec2d2ad8..cb9a4930a96 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -52,13 +52,12 @@ #define ZEND_LOGO_DATA_URI "data:image/png;base64,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" BEGIN_EXTERN_C() -PHPAPI zend_string *php_info_html_esc(char *string); -PHPAPI void php_info_html_esc_write(char *string, int str_len); +PHPAPI zend_string *php_info_html_esc(const char *string); PHPAPI void php_print_info_htmlhead(void); PHPAPI void php_print_info(int flag); PHPAPI void php_print_style(void); PHPAPI void php_info_print_style(void); -PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header); +PHPAPI void php_info_print_table_colspan_header(int num_cols, const char *header); PHPAPI void php_info_print_table_header(int num_cols, ...); PHPAPI void php_info_print_table_row(int num_cols, ...); PHPAPI void php_info_print_table_row_ex(int num_cols, const char *, ...); diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 096f432c9a2..7b8cb082366 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -386,7 +386,7 @@ void php_mail_log_to_file(char *filename, char *message, size_t message_size) { } -static int php_mail_detect_multiple_crlf(char *hdr) { +static int php_mail_detect_multiple_crlf(const char *hdr) { /* This function detects multiple/malformed multiple newlines. */ if (!hdr || !strlen(hdr)) { @@ -425,7 +425,7 @@ static int php_mail_detect_multiple_crlf(char *hdr) { /* {{{ php_mail */ -PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd) +PHPAPI int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd) { #ifdef PHP_WIN32 int tsm_err; @@ -436,14 +436,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char char *sendmail_path = INI_STR("sendmail_path"); char *sendmail_cmd = NULL; char *mail_log = INI_STR("mail.log"); - char *hdr = headers; + const char *hdr = headers; + char *ahdr = NULL; #if PHP_SIGCHILD void (*sig_handler)() = NULL; #endif #define MAIL_RET(val) \ - if (hdr != headers) { \ - efree(hdr); \ + if (ahdr != NULL) { \ + efree(ahdr); \ } \ return val; \ @@ -486,10 +487,11 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char f = php_basename(tmp, strlen(tmp), NULL, 0); if (headers != NULL && *headers) { - spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers); + spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers); } else { - spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f)); + spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f)); } + hdr = ahdr; zend_string_release_ex(f, 0); } diff --git a/ext/standard/math.c b/ext/standard/math.c index ca6c1f4b9d8..fe23a189c2f 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1026,8 +1026,8 @@ PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, c return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1); } -PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_point, - size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) +PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, + size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len) { zend_string *res; zend_string *tmpbuf; diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h index 728ea33fd11..b77cd0bda38 100644 --- a/ext/standard/php_http.h +++ b/ext/standard/php_http.h @@ -24,7 +24,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, size_t num_prefix_len, const char *key_prefix, size_t key_prefix_len, const char *key_suffix, size_t key_suffix_len, - zval *type, char *arg_sep, int enc_type); + zval *type, const char *arg_sep, int enc_type); #define php_url_encode_hash(ht, formstr) php_url_encode_hash_ex((ht), (formstr), NULL, 0, NULL, 0, NULL, 0, NULL) #endif diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h index d532496ea61..3649e62198b 100644 --- a/ext/standard/php_image.h +++ b/ext/standard/php_image.h @@ -50,7 +50,7 @@ typedef enum PHP_MINIT_FUNCTION(imagetypes); -PHPAPI int php_getimagetype(php_stream *stream, char *input, char *filetype); +PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetype); PHPAPI char * php_image_type_to_mime_type(int image_type); diff --git a/ext/standard/php_mail.h b/ext/standard/php_mail.h index 3a2ccdc4b12..2a561d55233 100644 --- a/ext/standard/php_mail.h +++ b/ext/standard/php_mail.h @@ -20,7 +20,7 @@ PHP_MINFO_FUNCTION(mail); PHPAPI zend_string *php_mail_build_headers(HashTable *headers); -PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd); +PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd); #define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \ do { \ diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h index a8d1f2dbf36..c3ce7cc7283 100644 --- a/ext/standard/php_math.h +++ b/ext/standard/php_math.h @@ -18,9 +18,9 @@ #ifndef PHP_MATH_H #define PHP_MATH_H -PHPAPI double _php_math_round(double, int, int); -PHPAPI zend_string *_php_math_number_format(double, int, char, char); -PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t); +PHPAPI double _php_math_round(double value, int places, int mode); +PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep); +PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len); PHPAPI zend_string * _php_math_longtobase(zval *arg, int base); PHPAPI zend_long _php_math_basetolong(zval *arg, int base); PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret); diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 7a813c26103..43e50dffc18 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -42,22 +42,22 @@ PHPAPI zend_string *php_string_tolower(zend_string *s); PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen); PHPAPI zend_string *php_addslashes(zend_string *str); PHPAPI void php_stripslashes(zend_string *str); -PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t what_len); -PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t what_len); +PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t what_len); +PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t what_len); PHPAPI void php_stripcslashes(zend_string *str); -PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t sufflen); +PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t sufflen); PHPAPI size_t php_dirname(char *str, size_t len); PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len); PHPAPI zend_string *php_str_to_str(const char *haystack, size_t length, const char *needle, size_t needle_len, const char *str, size_t str_len); -PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode); +PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode); PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len); PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, const char *allow, size_t allow_len, zend_bool allow_tag_spaces); PHPAPI void php_implode(const zend_string *delim, HashTable *arr, zval *return_value); PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit); -PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end); -PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end); +PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end); +PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end); PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive); PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2); diff --git a/ext/standard/php_uuencode.h b/ext/standard/php_uuencode.h index 82549f56d13..5d5c84a9b38 100644 --- a/ext/standard/php_uuencode.h +++ b/ext/standard/php_uuencode.h @@ -17,7 +17,7 @@ #ifndef PHP_UUENCODE_H #define PHP_UUENCODE_H -PHPAPI zend_string *php_uudecode(char *src, size_t src_len); -PHPAPI zend_string *php_uuencode(char *src, size_t src_len); +PHPAPI zend_string *php_uudecode(const char *src, size_t src_len); +PHPAPI zend_string *php_uuencode(const char *src, size_t src_len); #endif /* PHP_UUENCODE_H */ diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c index 269fe8a9476..562e6e9de68 100644 --- a/ext/standard/sha1.c +++ b/ext/standard/sha1.c @@ -21,7 +21,7 @@ #include "sha1.h" #include "md5.h" -PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest) +PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest) { make_digest_ex(sha1str, digest, 20); } diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h index 81a9cae460a..c904969dd36 100644 --- a/ext/standard/sha1.h +++ b/ext/standard/sha1.h @@ -29,6 +29,6 @@ typedef struct { PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *); PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, size_t); PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *); -PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest); +PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest); #endif diff --git a/ext/standard/string.c b/ext/standard/string.c index 06ad0f2d249..635f5daf8f5 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -765,7 +765,7 @@ static inline int php_charmask(const unsigned char *input, size_t len, char *mas * mode 3 : trim left and right * what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0') */ -static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what, size_t what_len, int mode) +static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode) { const char *start = ZSTR_VAL(str); const char *end = start + ZSTR_LEN(str); @@ -793,7 +793,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what } } } else { - php_charmask((unsigned char*)what, what_len, mask); + php_charmask((const unsigned char *) what, what_len, mask); if (mode & 1) { while (start != end) { @@ -857,7 +857,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what * mode 3 : trim left and right * what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0') */ -PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode) +PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode) { return php_trim_int(str, what, what_len, mode); } @@ -1508,7 +1508,7 @@ PHP_FUNCTION(strtolower) /* {{{ php_basename */ -PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t suffix_len) +PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t suffix_len) { /* State 0 is directly after a directory separator (or at the start of the string). * State 1 is everything else. */ @@ -1745,7 +1745,7 @@ PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len) /* {{{ php_strspn */ -PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end) +PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end) { register const char *p = s1, *spanp; register char c = *p; @@ -1763,7 +1763,7 @@ cont: /* {{{ php_strcspn */ -PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end) +PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end) { register const char *p, *spanp; register char c = *s1; @@ -2720,7 +2720,7 @@ PHP_FUNCTION(ucwords) RETURN_EMPTY_STRING(); } - php_charmask((unsigned char *)delims, delims_len, mask); + php_charmask((const unsigned char *) delims, delims_len, mask); ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); r = Z_STRVAL_P(return_value); @@ -3642,7 +3642,7 @@ PHPAPI void php_stripcslashes(zend_string *str) /* {{{ php_addcslashes_str */ -PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t wlength) +PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t wlength) { char flags[256]; char *target; @@ -3651,7 +3651,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t newlen; zend_string *new_str = zend_string_safe_alloc(4, len, 0, 0); - php_charmask((unsigned char *)what, wlength, flags); + php_charmask((const unsigned char *) what, wlength, flags); for (source = str, end = source + len, target = ZSTR_VAL(new_str); source < end; source++) { c = *source; @@ -3685,7 +3685,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, /* {{{ php_addcslashes */ -PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t wlength) +PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t wlength) { return php_addcslashes_str(ZSTR_VAL(str), ZSTR_LEN(str), what, wlength); } @@ -5909,7 +5909,7 @@ PHP_FUNCTION(str_word_count) } if (char_list) { - php_charmask((unsigned char *)char_list, char_list_len, ch); + php_charmask((const unsigned char *) char_list, char_list_len, ch); } p = ZSTR_VAL(str); diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h index a756db65864..6252fdce544 100644 --- a/ext/standard/url_scanner_ex.h +++ b/ext/standard/url_scanner_ex.h @@ -24,10 +24,10 @@ PHP_RINIT_FUNCTION(url_scanner_ex); PHP_RSHUTDOWN_FUNCTION(url_scanner_ex); PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode); -PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode); +PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode); PHPAPI int php_url_scanner_reset_session_var(zend_string *name, int encode); PHPAPI int php_url_scanner_reset_session_vars(void); -PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode); +PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode); PHPAPI int php_url_scanner_reset_var(zend_string *name, int encode); PHPAPI int php_url_scanner_reset_vars(void); diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index d80bd0d2a10..bef17733e2f 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -725,7 +725,7 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0); } -static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char *value, size_t value_len, int encode, int type) +static inline int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type) { smart_str sname = {0}; smart_str svalue = {0}; @@ -758,9 +758,9 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); encoded = php_raw_url_encode(value, value_len); smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); - encoded = php_escape_html_entities_ex((unsigned char*)name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1); + encoded = php_escape_html_entities_ex((const unsigned char *) name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1); smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); - encoded = php_escape_html_entities_ex((unsigned char*)value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1); + encoded = php_escape_html_entities_ex((const unsigned char *) value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1); smart_str_appendl(&hvalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appendl(&sname, name, name_len); @@ -788,13 +788,13 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char } -PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode) +PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode) { return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 1); } -PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode) +PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode) { return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 0); } @@ -860,7 +860,7 @@ static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode, encoded = php_raw_url_encode(ZSTR_VAL(name), ZSTR_LEN(name)); smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); - encoded = php_escape_html_entities_ex((unsigned char *)ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1); + encoded = php_escape_html_entities_ex((const unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1); smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c index 036e190f242..b00ddb520d5 100644 --- a/ext/standard/uuencode.c +++ b/ext/standard/uuencode.c @@ -61,10 +61,11 @@ #define PHP_UU_DEC(c) (((c) - ' ') & 077) -PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */ +PHPAPI zend_string *php_uuencode(const char *src, size_t src_len) /* {{{ */ { size_t len = 45; - unsigned char *p, *s, *e, *ee; + unsigned char *p; + const unsigned char *s, *e, *ee; zend_string *dest; /* encoded length is ~ 38% greater than the original @@ -125,10 +126,11 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */ } /* }}} */ -PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */ +PHPAPI zend_string *php_uudecode(const char *src, size_t src_len) /* {{{ */ { size_t len, total_len=0; - char *s, *e, *p, *ee; + char *p; + const char *s, *e, *ee; zend_string *dest; dest = zend_string_alloc((size_t) ceil(src_len * 0.75), 0); diff --git a/main/SAPI.c b/main/SAPI.c index 5ad40eec1e1..b2840c18e90 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -610,7 +610,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) { } } -SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace) +SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace) { sapi_header_line ctr = {0}; int r; @@ -622,7 +622,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_ &ctr); if (!duplicate) - efree(header_line); + efree((void *) header_line); return r; } @@ -682,7 +682,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg) if (!p->line || !p->line_len) { return FAILURE; } - header_line = p->line; + header_line = estrndup(p->line, p->line_len); header_line_len = p->line_len; http_response_code = p->response_code; break; @@ -699,8 +699,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg) return FAILURE; } - header_line = estrndup(header_line, header_line_len); - /* cut off trailing spaces, linefeeds and carriage-returns */ if (header_line_len && isspace(header_line[header_line_len-1])) { do { @@ -982,7 +980,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva return SUCCESS; } -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)) +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)) { if (SG(sapi_started) && EG(current_execute_data)) { return FAILURE; @@ -1014,7 +1012,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void) } } -SAPI_API char *sapi_getenv(char *name, size_t name_len) +SAPI_API char *sapi_getenv(const char *name, size_t name_len) { if (!strncasecmp(name, "HTTP_PROXY", name_len)) { /* Ugly fix for HTTP_PROXY issue, see bug #72573 */ @@ -1101,10 +1099,10 @@ SAPI_API void sapi_terminate_process(void) { } } -SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */ +SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */ { zval *return_value = (zval*)arg; - char *str = NULL; + char *buf = NULL; ALLOCA_FLAG(use_heap) @@ -1115,11 +1113,12 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val var[3] == 'P' && var[4] == '_') { - char *p; + const char *p; + char *str; var_len -= 5; p = var + 5; - var = str = do_alloca(var_len + 1, use_heap); + var = str = buf = do_alloca(var_len + 1, use_heap); *str++ = *p++; while (*p) { if (*p == '_') { @@ -1145,8 +1144,8 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val return; } add_assoc_stringl_ex(return_value, var, var_len, val, val_len); - if (str) { - free_alloca(var, use_heap); + if (buf) { + free_alloca(buf, use_heap); } } /* }}} */ diff --git a/main/SAPI.h b/main/SAPI.h index d1ef8a40b08..b0d2928369f 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -145,7 +145,7 @@ SAPI_API void sapi_shutdown(void); SAPI_API void sapi_activate(void); SAPI_API void sapi_deactivate(void); SAPI_API void sapi_initialize_empty_request(void); -SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg); +SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg); END_EXTERN_C() /* @@ -160,7 +160,7 @@ END_EXTERN_C() */ typedef struct { - char *line; /* If you allocated this, you need to free it yourself */ + const char *line; /* If you allocated this, you need to free it yourself */ size_t line_len; zend_long response_code; /* long due to zend_parse_parameters compatibility */ } sapi_header_line; @@ -177,7 +177,7 @@ BEGIN_EXTERN_C() SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg); /* Deprecated functions. Use sapi_header_op instead. */ -SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace); +SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace); #define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1) @@ -190,11 +190,11 @@ SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry); SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry); SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void)); SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray)); -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)); +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)); SAPI_API int sapi_flush(void); SAPI_API zend_stat_t *sapi_get_stat(void); -SAPI_API char *sapi_getenv(char *name, size_t name_len); +SAPI_API char *sapi_getenv(const char *name, size_t name_len); SAPI_API char *sapi_get_default_content_type(void); SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header); @@ -223,7 +223,7 @@ struct _sapi_module_struct { size_t (*ub_write)(const char *str, size_t str_length); void (*flush)(void *server_context); zend_stat_t *(*get_stat)(void); - char *(*getenv)(char *name, size_t name_len); + char *(*getenv)(const char *name, size_t name_len); void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); @@ -235,7 +235,7 @@ struct _sapi_module_struct { char *(*read_cookies)(void); void (*register_server_variables)(zval *track_vars_array); - void (*log_message)(char *message, int syslog_type_int); + void (*log_message)(const char *message, int syslog_type_int); double (*get_request_time)(void); void (*terminate_process)(void); @@ -255,7 +255,7 @@ struct _sapi_module_struct { int (*get_target_uid)(uid_t *); int (*get_target_gid)(gid_t *); - unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len); + unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len); void (*ini_defaults)(HashTable *configuration_hash); int phpinfo_as_text; @@ -288,7 +288,7 @@ struct _sapi_post_entry { #define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg) #define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray) -#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) +#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) BEGIN_EXTERN_C() SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data); diff --git a/main/fastcgi.h b/main/fastcgi.h index 5e15c14d4b2..71c8517b11d 100644 --- a/main/fastcgi.h +++ b/main/fastcgi.h @@ -75,7 +75,7 @@ typedef enum _fcgi_protocol_status { /* FastCGI client API */ -typedef void (*fcgi_apply_func)(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg); +typedef void (*fcgi_apply_func)(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg); #define FCGI_HASH_TABLE_SIZE 128 #define FCGI_HASH_TABLE_MASK (FCGI_HASH_TABLE_SIZE - 1) diff --git a/main/main.c b/main/main.c index 8599022c138..119fbb26dfd 100644 --- a/main/main.c +++ b/main/main.c @@ -822,7 +822,7 @@ PHPAPI int php_get_module_initialized(void) /* {{{ php_log_err_with_severity */ -PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int) +PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int) { int fd = -1; time_t error_time; diff --git a/main/network.c b/main/network.c index 432c9e5a04b..b8ed1a2ca19 100644 --- a/main/network.c +++ b/main/network.c @@ -768,7 +768,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock, /* {{{ php_network_connect_socket_to_host */ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port, int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string, - int *error_code, char *bindto, unsigned short bindport, long sockopts + int *error_code, const char *bindto, unsigned short bindport, long sockopts ) { int num_addrs, n, fatal = 0; @@ -1307,7 +1307,7 @@ struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char * #endif #endif -PHPAPI struct hostent* php_network_gethostbyname(char *name) { +PHPAPI struct hostent* php_network_gethostbyname(const char *name) { #if !defined(HAVE_GETHOSTBYNAME_R) return gethostbyname(name); #else diff --git a/main/php.h b/main/php.h index b6d9669be41..76ced5907ec 100644 --- a/main/php.h +++ b/main/php.h @@ -318,7 +318,7 @@ PHPAPI int php_get_module_initialized(void); #else #define php_log_err(msg) php_log_err_with_severity(msg, 5) #endif -PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int); +PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int); int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2); int cfgparse(void); END_EXTERN_C() diff --git a/main/php_ini.c b/main/php_ini.c index ec847af4096..63d3db09b84 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -778,7 +778,7 @@ void php_ini_register_extensions(void) /* {{{ php_parse_user_ini_file */ -PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash) +PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash) { zend_stat_t sb; char ini_file[MAXPATHLEN]; diff --git a/main/php_ini.h b/main/php_ini.h index 9d977c1bac0..7fd7cdd1cef 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -29,7 +29,7 @@ PHPAPI zval *cfg_get_entry(const char *name, size_t name_length); PHPAPI int cfg_get_long(const char *varname, zend_long *result); PHPAPI int cfg_get_double(const char *varname, double *result); PHPAPI int cfg_get_string(const char *varname, char **result); -PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash); +PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash); PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage); PHPAPI int php_ini_has_per_dir_config(void); PHPAPI int php_ini_has_per_host_config(void); diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index 17bc509a193..5d0b978aada 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -40,12 +40,12 @@ BEGIN_EXTERN_C() PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC); -PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC); +PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC); PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC); PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC); PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC); -PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC); +PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC); PHPAPI int php_stream_mode_from_str(const char *mode); PHPAPI const char *_php_stream_mode_to_str(int mode); diff --git a/main/php_network.h b/main/php_network.h index e96cbd37d3c..437069b4fcc 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -241,7 +241,7 @@ PHPAPI void php_network_freeaddresses(struct sockaddr **sal); PHPAPI php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port, int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string, - int *error_code, char *bindto, unsigned short bindport, long sockopts + int *error_code, const char *bindto, unsigned short bindport, long sockopts ); PHPAPI int php_network_connect_socket(php_socket_t sockfd, @@ -315,7 +315,7 @@ PHPAPI void php_network_populate_name_from_sockaddr( PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_long addrlen, struct sockaddr *sa, socklen_t *sl); -PHPAPI struct hostent* php_network_gethostbyname(char *name); +PHPAPI struct hostent* php_network_gethostbyname(const char *name); PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block); END_EXTERN_C() diff --git a/main/php_variables.c b/main/php_variables.c index b41286312dc..89b3dbf2d69 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -30,13 +30,13 @@ void _php_import_environment_variables(zval *array_ptr); PHPAPI void (*php_import_environment_variables)(zval *array_ptr) = _php_import_environment_variables; -PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array) +PHPAPI void php_register_variable(const char *var, const char *strval, zval *track_vars_array) { php_register_variable_safe(var, strval, strlen(strval), track_vars_array); } /* binary-safe version */ -PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array) +PHPAPI void php_register_variable_safe(const char *var, const char *strval, size_t str_len, zval *track_vars_array) { zval new_entry; assert(strval != NULL); @@ -60,7 +60,7 @@ static zend_always_inline void php_register_variable_quick(const char *name, siz zend_string_release_ex(key, 0); } -PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array) +PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *track_vars_array) { char *p = NULL; char *ip = NULL; /* index pointer */ @@ -593,11 +593,10 @@ zend_bool php_std_auto_global_callback(char *name, uint32_t name_len) /* {{{ php_build_argv */ -PHPAPI void php_build_argv(char *s, zval *track_vars_array) +PHPAPI void php_build_argv(const char *s, zval *track_vars_array) { zval arr, argc, tmp; int count = 0; - char *ss, *space; if (!(SG(request_info).argc || track_vars_array)) { return; @@ -615,24 +614,18 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array) } } } else if (s && *s) { - ss = s; - while (ss) { - space = strchr(ss, '+'); - if (space) { - *space = '\0'; - } + while (1) { + const char *space = strchr(s, '+'); /* auto-type */ - ZVAL_STRING(&tmp, ss); + ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s)); count++; if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) { zend_string_efree(Z_STR(tmp)); } - if (space) { - *space = '+'; - ss = space + 1; - } else { - ss = space; + if (!space) { + break; } + s = space + 1; } } diff --git a/main/php_variables.h b/main/php_variables.h index dc052def89e..c6ccbe6a721 100644 --- a/main/php_variables.h +++ b/main/php_variables.h @@ -32,12 +32,12 @@ BEGIN_EXTERN_C() void php_startup_auto_globals(void); extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr); -PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array); +PHPAPI void php_register_variable(const char *var, const char *val, zval *track_vars_array); /* binary-safe version */ -PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array); -PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array); +PHPAPI void php_register_variable_safe(const char *var, const char *val, size_t val_len, zval *track_vars_array); +PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_vars_array); -PHPAPI void php_build_argv(char *s, zval *track_vars_array); +PHPAPI void php_build_argv(const char *s, zval *track_vars_array); PHPAPI int php_hash_environment(void); END_EXTERN_C() diff --git a/main/streams/memory.c b/main/streams/memory.c index cd3a5cb9505..0def3b1a3d7 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -315,7 +315,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC) /* {{{ */ -PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC) +PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC) { php_stream *stream; php_stream_memory_data *ms; @@ -325,7 +325,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) { /* use the buffer directly */ - ms->data = buf; + ms->data = (char *) buf; ms->fsize = length; } else { if (length) { @@ -598,7 +598,7 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR /* }}} */ /* {{{ _php_stream_temp_open */ -PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC) +PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC) { php_stream *stream; php_stream_temp_data *ts; diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 52bc44f94a9..126d09b1c6a 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -243,7 +243,7 @@ php_apache_sapi_read_cookies(void) } static char * -php_apache_sapi_getenv(char *name, size_t name_len) +php_apache_sapi_getenv(const char *name, size_t name_len) { php_struct *ctx = SG(server_context); const char *env_var; @@ -305,7 +305,7 @@ php_apache_sapi_flush(void *server_context) } } -static void php_apache_sapi_log_message(char *msg, int syslog_type_int) +static void php_apache_sapi_log_message(const char *msg, int syslog_type_int) { php_struct *ctx; int aplog_type = APLOG_ERR; @@ -354,7 +354,7 @@ static void php_apache_sapi_log_message(char *msg, int syslog_type_int) } } -static void php_apache_sapi_log_message_ex(char *msg, request_rec *r) +static void php_apache_sapi_log_message_ex(const char *msg, request_rec *r) { if (r) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, msg, r->filename); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 5718d1b3f30..0dfcdb84ef5 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -553,7 +553,7 @@ static char *cgi_getenv_win32(const char *name, size_t name_len) } #endif -static char *sapi_cgi_getenv(char *name, size_t name_len) +static char *sapi_cgi_getenv(const char *name, size_t name_len) { #ifndef PHP_WIN32 return getenv(name); @@ -562,7 +562,7 @@ static char *sapi_cgi_getenv(char *name, size_t name_len) #endif } -static char *sapi_fcgi_getenv(char *name, size_t name_len) +static char *sapi_fcgi_getenv(const char *name, size_t name_len) { /* when php is started by mod_fastcgi, no regular environment * is provided to PHP. It is always sent to PHP at the start @@ -646,10 +646,10 @@ static char *sapi_fcgi_read_cookies(void) return FCGI_GETENV(request, "HTTP_COOKIE"); } -static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) +static void cgi_php_load_env_var(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) { - zval *array_ptr = (zval*)arg; - int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER; + zval *array_ptr = (zval *) arg; + int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) ? PARSE_ENV : PARSE_SERVER; size_t new_val_len; if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len)) { @@ -747,7 +747,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array) } } -static void sapi_cgi_log_message(char *message, int syslog_type_int) +static void sapi_cgi_log_message(const char *message, int syslog_type_int) { if (fcgi_is_fastcgi() && CGIG(fcgi_logging)) { fcgi_request *request; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index f116bc475fd..206d393b7e8 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -354,7 +354,7 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */ } /* }}} */ -static void sapi_cli_log_message(char *message, int syslog_type_int) /* {{{ */ +static void sapi_cli_log_message(const char *message, int syslog_type_int) /* {{{ */ { fprintf(stderr, "%s\n", message); #ifdef PHP_WIN32 diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 4a25455374c..ec658eb738e 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -748,7 +748,7 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */ zend_hash_apply_with_arguments(&client->request.headers, (apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array); } /* }}} */ -static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */ +static void sapi_cli_server_log_write(int type, const char *msg) /* {{{ */ { char buf[52]; @@ -777,7 +777,7 @@ static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */ #endif } /* }}} */ -static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */ +static void sapi_cli_server_log_message(const char *msg, int syslog_type_int) /* {{{ */ { sapi_cli_server_log_write(PHP_CLI_SERVER_LOG_MESSAGE, msg); } /* }}} */ @@ -1979,7 +1979,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server php_cli_server_content_sender_ctor(&client->content_sender); client->content_sender_initialized = 1; - escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, /* double_encode */ 0, /* quiet */ 0); + escaped_request_uri = php_escape_html_entities_ex((const unsigned char *) client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, /* double_encode */ 0, /* quiet */ 0); { static const char prologue_template[] = "%d %s"; diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index 1713534a23d..1d1d43e56b2 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -91,9 +91,9 @@ static void php_embed_send_header(sapi_header_struct *sapi_header, void *server_ { } -static void php_embed_log_message(char *message, int syslog_type_int) +static void php_embed_log_message(const char *message, int syslog_type_int) { - fprintf (stderr, "%s\n", message); + fprintf(stderr, "%s\n", message); } static void php_embed_register_variables(zval *track_vars_array) diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 5ca3c39811c..c2a1bd5df32 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -107,7 +107,7 @@ static int parent = 1; static int request_body_fd; static int fpm_is_running = 0; -static char *sapi_cgibin_getenv(char *name, size_t name_len); +static char *sapi_cgibin_getenv(const char *name, size_t name_len); static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg); #define PHP_MODE_STANDARD 1 @@ -464,7 +464,7 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes) /* {{{ */ } /* }}} */ -static char *sapi_cgibin_getenv(char *name, size_t name_len) /* {{{ */ +static char *sapi_cgibin_getenv(const char *name, size_t name_len) /* {{{ */ { /* if fpm has started, use fcgi env */ if (fpm_is_running) { @@ -501,10 +501,10 @@ static char *sapi_cgi_read_cookies(void) /* {{{ */ } /* }}} */ -static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */ +static void cgi_php_load_env_var(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */ { - zval *array_ptr = (zval*)arg; - int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER; + zval *array_ptr = (zval *) arg; + int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) ? PARSE_ENV : PARSE_SERVER; size_t new_val_len; if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len)) { @@ -607,7 +607,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len) /* {{{ sapi_cgi_log_message */ -static void sapi_cgi_log_message(char *message, int syslog_type_int) +static void sapi_cgi_log_message(const char *message, int syslog_type_int) { zlog_msg(ZLOG_NOTICE, "PHP message: ", message); } diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index d940ba661c0..18d5dae0860 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -48,7 +48,7 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_ } /* }}} */ -static void fpm_php_disable(char *value, int (*zend_disable)(char *, size_t)) /* {{{ */ +static void fpm_php_disable(char *value, int (*zend_disable)(const char *, size_t)) /* {{{ */ { char *s = 0, *e = value; diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 6b8f7785a42..02f2eae55a8 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -488,7 +488,7 @@ int fpm_status_handle_request(void) /* {{{ */ if (!encode) { query_string = proc.query_string; } else { - tmp_query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, /* double_encode */ 1, /* quiet */ 0); + tmp_query_string = php_escape_html_entities_ex((const unsigned char *) proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, /* double_encode */ 1, /* quiet */ 0); query_string = ZSTR_VAL(tmp_query_string); } } diff --git a/sapi/fuzzer/fuzzer-sapi.c b/sapi/fuzzer/fuzzer-sapi.c index eb452788b10..ca474af1ee8 100644 --- a/sapi/fuzzer/fuzzer-sapi.c +++ b/sapi/fuzzer/fuzzer-sapi.c @@ -72,7 +72,7 @@ static void register_variables(zval *track_vars_array) php_import_environment_variables(track_vars_array); } -static void log_message(char *message, int level) +static void log_message(const char *message, int level) { } diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 1a6527a68b6..6fec0c2b54d 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -191,7 +191,7 @@ static int sapi_lsapi_deactivate(void) /* {{{ sapi_lsapi_getenv */ -static char *sapi_lsapi_getenv( char * name, size_t name_len ) +static char *sapi_lsapi_getenv(const char * name, size_t name_len ) { if ( lsapi_mode ) { return LSAPI_GetEnv( name ); @@ -509,7 +509,7 @@ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers) /* {{{ sapi_lsapi_send_headers */ -static void sapi_lsapi_log_message(char *message, int syslog_type_int) +static void sapi_lsapi_log_message(const char *message, int syslog_type_int) { char buf[8192]; int len = strlen( message ); @@ -521,7 +521,7 @@ static void sapi_lsapi_log_message(char *message, int syslog_type_int) len = 8191; ++len; } - LSAPI_Write_Stderr( message, len); + LSAPI_Write_Stderr( message, len ); } /* }}} */ diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 78aa34f524d..ea0653fd25e 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -772,7 +772,7 @@ static void php_sapi_phpdbg_send_header(sapi_header_struct *sapi_header, void *s } /* }}} */ -static void php_sapi_phpdbg_log_message(char *message, int syslog_type_int) /* {{{ */ +static void php_sapi_phpdbg_log_message(const char *message, int syslog_type_int) /* {{{ */ { /* * We must not request TSRM before being booted diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 61f17d1c0ef..757d48e7395 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -737,10 +737,9 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async return SUCCESS; } /* }}} */ -PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */ +PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */ { char buf[PHPDBG_MAX_CMD]; - char *cmd = NULL; char *buffer = NULL; if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) { @@ -755,11 +754,12 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */ #endif { phpdbg_write("prompt", "", "%s", phpdbg_get_prompt()); - phpdbg_consume_stdin_line(cmd = buf); + phpdbg_consume_stdin_line(buf); + buffer = estrdup(buf); } #ifdef HAVE_PHPDBG_READLINE else { - cmd = readline(phpdbg_get_prompt()); + char *cmd = readline(phpdbg_get_prompt()); PHPDBG_G(last_was_newline) = 1; if (!cmd) { @@ -768,19 +768,13 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */ } add_history(cmd); + buffer = estrdup(cmd); + free(cmd); } #endif } else { - cmd = buffered; + buffer = estrdup(buffered); } - - buffer = estrdup(cmd); - -#ifdef HAVE_PHPDBG_READLINE - if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) { - free(cmd); - } -#endif } if (buffer && isspace(*buffer)) { diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h index dd80e61db3a..3cc07d1a70c 100644 --- a/sapi/phpdbg/phpdbg_cmd.h +++ b/sapi/phpdbg/phpdbg_cmd.h @@ -125,8 +125,8 @@ typedef struct { /* * Input Management */ -PHPDBG_API char* phpdbg_read_input(char *buffered); -PHPDBG_API void phpdbg_destroy_input(char**); +PHPDBG_API char *phpdbg_read_input(const char *buffered); +PHPDBG_API void phpdbg_destroy_input(char **input); PHPDBG_API int phpdbg_ask_user_permission(const char *question); /** diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c index 7cc84b72dcf..df925b64024 100644 --- a/sapi/phpdbg/phpdbg_print.c +++ b/sapi/phpdbg/phpdbg_print.c @@ -375,7 +375,7 @@ void phpdbg_print_opcodes_class(const char *class) { phpdbg_print_opcodes_ce(ce); } -PHPDBG_API void phpdbg_print_opcodes(char *function) +PHPDBG_API void phpdbg_print_opcodes(const char *function) { if (function == NULL) { phpdbg_print_opcodes_main(); @@ -401,12 +401,12 @@ PHPDBG_API void phpdbg_print_opcodes(char *function) } } ZEND_HASH_FOREACH_END(); } else { - function = zend_str_tolower_dup(function, strlen(function)); + char *function_lowercase = zend_str_tolower_dup(function, strlen(function)); - if (strstr(function, "::") == NULL) { - phpdbg_print_opcodes_function(function, strlen(function)); + if (strstr(function_lowercase, "::") == NULL) { + phpdbg_print_opcodes_function(function_lowercase, strlen(function_lowercase)); } else { - char *method_name, *class_name = strtok(function, "::"); + char *method_name, *class_name = strtok(function_lowercase, "::"); if ((method_name = strtok(NULL, "::")) == NULL) { phpdbg_print_opcodes_class(class_name); } else { @@ -414,6 +414,6 @@ PHPDBG_API void phpdbg_print_opcodes(char *function) } } - efree(function); + efree(function_lowercase); } } diff --git a/sapi/phpdbg/phpdbg_print.h b/sapi/phpdbg/phpdbg_print.h index 79a77ad2a63..14f5bf69393 100644 --- a/sapi/phpdbg/phpdbg_print.h +++ b/sapi/phpdbg/phpdbg_print.h @@ -33,7 +33,7 @@ PHPDBG_PRINT(method); PHPDBG_PRINT(func); PHPDBG_PRINT(stack); -PHPDBG_API void phpdbg_print_opcodes(char *function); +PHPDBG_API void phpdbg_print_opcodes(const char *function); extern const phpdbg_command_t phpdbg_print_commands[]; diff --git a/win32/sendmail.c b/win32/sendmail.c index 281c3435334..ff57da88c2d 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -122,7 +122,7 @@ static char *ErrorMessages[] = * Returns NULL on error, or the new char* buffer on success. * You have to take care and efree() the buffer on your own. */ -static zend_string *php_win32_mail_trim_header(char *header) +static zend_string *php_win32_mail_trim_header(const char *header) { zend_string *result, *result2; zend_string *replace; @@ -176,14 +176,14 @@ static zend_string *php_win32_mail_trim_header(char *header) // // See SendText() for additional args! //********************************************************************/ -PHPAPI int TSendMail(char *host, int *error, char **error_message, - char *headers, char *Subject, char *mailTo, char *data, +PHPAPI int TSendMail(const char *host, int *error, char **error_message, + const char *headers, const char *Subject, const char *mailTo, const char *data, char *mailCc, char *mailBcc, char *mailRPath) { int ret; char *RPath = NULL; zend_string *headers_lc = NULL, *headers_trim = NULL; /* headers_lc is only created if we've a header at all */ - char *pos1 = NULL, *pos2 = NULL; + const char *pos1 = NULL, *pos2 = NULL; if (host == NULL) { *error = BAD_MAIL_HOST; @@ -216,7 +216,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message, RPath = estrdup(INI_STR("sendmail_from")); } else if (headers_lc) { int found = 0; - char *lookup = ZSTR_VAL(headers_lc); + const char *lookup = ZSTR_VAL(headers_lc); while (lookup) { pos1 = strstr(lookup, "from:"); @@ -352,12 +352,13 @@ PHPAPI char *GetSMErrorText(int index) // Author/Date: jcar 20/9/96 // History: //*******************************************************************/ -static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, - char *headers, char *headers_lc, char **error_message) +static int SendText(char *RPath, const char *Subject, const char *mailTo, char *mailCc, char *mailBcc, const char *data, + const char *headers, char *headers_lc, char **error_message) { int res; char *p; - char *tempMailTo, *token, *pos1, *pos2; + char *tempMailTo, *token; + const char *pos1, *pos2; char *server_response = NULL; char *stripped_header = NULL; zend_string *data_cln; @@ -633,7 +634,7 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char return (SUCCESS); } -static int addToHeader(char **header_buffer, const char *specifier, char *string) +static int addToHeader(char **header_buffer, const char *specifier, const char *string) { *header_buffer = erealloc(*header_buffer, strlen(*header_buffer) + strlen(specifier) + strlen(string) + 1); sprintf(*header_buffer + strlen(*header_buffer), specifier, string); @@ -651,7 +652,7 @@ static int addToHeader(char **header_buffer, const char *specifier, char *string // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders) +static int PostHeader(char *RPath, const char *Subject, const char *mailTo, char *xheaders) { /* Print message header according to RFC 822 */ /* Return-path, Received, Date, From, Subject, Sender, To, cc */ diff --git a/win32/sendmail.h b/win32/sendmail.h index bb502cb7ddc..486482c0c0c 100644 --- a/win32/sendmail.h +++ b/win32/sendmail.h @@ -32,16 +32,16 @@ #define MAX_ERROR_INDEX 22 /* Always last error message + 1 */ -PHPAPI int TSendMail(char *smtpaddr, int *returnerror, char **error_message, - char *RPath, char *Subject, char *mailTo, char *data, +PHPAPI int TSendMail(const char *host, int *error, char **error_message, + const char *headers, const char *Subject, const char *mailTo, const char *data, char *mailCc, char *mailBcc, char *mailRPath); PHPAPI void TSMClose(void); -static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, - char *headers, char *headers_lc, char **error_message); +static int SendText(char *RPath, const char *Subject, const char *mailTo, char *mailCc, char *mailBcc, const char *data, + const char *headers, char *headers_lc, char **error_message); PHPAPI char *GetSMErrorText(int index); static int MailConnect(); -static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders); +static int PostHeader(char *RPath, const char *Subject, const char *mailTo, char *xheaders); static int Post(LPCSTR msg); static int Ack(char **server_response); static unsigned long GetAddr(LPSTR szHost);