summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c22
-rw-r--r--main/SAPI.h23
-rw-r--r--main/fopen_wrappers.c26
-rw-r--r--main/main.c104
-rw-r--r--main/network.c16
-rw-r--r--main/output.c36
-rw-r--r--main/php.h6
-rw-r--r--main/php_globals.h20
-rw-r--r--main/php_ini.c44
-rw-r--r--main/php_ini.h3
-rw-r--r--main/php_network.h2
-rw-r--r--main/php_output.h2
-rw-r--r--main/php_stdint.h1
-rw-r--r--main/php_streams.h19
-rw-r--r--main/php_variables.c52
-rw-r--r--main/php_variables.h2
-rw-r--r--main/php_version.h1
-rw-r--r--main/rfc1867.c32
-rw-r--r--main/rfc1867.h2
-rw-r--r--main/snprintf.c29
-rw-r--r--main/snprintf.h9
-rw-r--r--main/spprintf.c33
-rw-r--r--main/spprintf.h4
-rw-r--r--main/streams/cast.c14
-rw-r--r--main/streams/glob_wrapper.c6
-rw-r--r--main/streams/memory.c12
-rw-r--r--main/streams/mmap.c2
-rw-r--r--main/streams/php_stream_glob_wrapper.h4
-rw-r--r--main/streams/php_stream_mmap.h2
-rw-r--r--main/streams/php_stream_transport.h18
-rw-r--r--main/streams/plain_wrapper.c42
-rw-r--r--main/streams/streams.c32
-rw-r--r--main/streams/transports.c2
-rw-r--r--main/streams/userspace.c18
-rw-r--r--main/streams/xp_socket.c26
35 files changed, 371 insertions, 295 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index f2a0b26779..4771ea7d02 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -269,7 +269,7 @@ SAPI_API int sapi_read_post_block(char *buffer, size_t buflen TSRMLS_DC)
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
{
if ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "POST Content-Length of %pd bytes exceeds the limit of %pd bytes",
SG(request_info).content_length, SG(post_max_size));
return;
}
@@ -290,7 +290,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
}
if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds %ld bytes", SG(post_max_size));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_LONG_FMT " bytes", SG(post_max_size));
break;
}
@@ -739,7 +739,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
return SUCCESS;
} else {
/* new line/NUL character safety check */
- int i;
+ uint i;
for (i = 0; i < header_line_len; i++) {
/* RFC 2616 allows new lines if followed by SP or HT */
int illegal_break =
@@ -789,9 +789,9 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* Disable possible output compression for images */
if (!strncmp(ptr, "image/", sizeof("image/")-1)) {
- zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
- zend_alter_ini_entry(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_alter_ini_entry_chars(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string_release(key);
}
mimetype = estrdup(ptr);
@@ -817,10 +817,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
* do disable compression altogether. This contributes to making scripts
* portable between setups that have and don't have zlib compression
* enabled globally. See req #44164 */
- zend_string *key = STR_INIT("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
- zend_alter_ini_entry(key,
+ zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
+ zend_alter_ini_entry_chars(key,
"0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- STR_RELEASE(key);
+ zend_string_release(key);
} else if (!STRCASECMP(header_line, "Location")) {
if ((SG(sapi_headers).http_response_code < 300 ||
SG(sapi_headers).http_response_code > 399) &&
@@ -984,7 +984,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, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC)
+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 TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC)
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
@@ -1004,7 +1004,7 @@ SAPI_API int sapi_flush(TSRMLS_D)
}
}
-SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
+SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D)
{
if (sapi_module.get_stat) {
return sapi_module.get_stat(TSRMLS_C);
diff --git a/main/SAPI.h b/main/SAPI.h
index ac3db56bad..9172a3e4dd 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -31,6 +31,7 @@
#include "win32/php_stdint.h"
#endif
#include <sys/stat.h>
+#include "php.h"
#define SAPI_OPTION_NO_CHDIR 1
#define SAPI_POST_BLOCK_SIZE 0x4000
@@ -81,7 +82,7 @@ typedef struct {
const char *request_method;
char *query_string;
char *cookie_data;
- long content_length;
+ zend_long content_length;
char *path_translated;
char *request_uri;
@@ -124,11 +125,11 @@ typedef struct _sapi_globals_struct {
int64_t read_post_bytes;
unsigned char post_read;
unsigned char headers_sent;
- struct stat global_stat;
+ zend_stat_t global_stat;
char *default_mimetype;
char *default_charset;
HashTable *rfc1867_uploaded_files;
- long post_max_size;
+ zend_long post_max_size;
int options;
zend_bool sapi_started;
double global_request_time;
@@ -169,7 +170,7 @@ END_EXTERN_C()
typedef struct {
char *line; /* If you allocated this, you need to free it yourself */
uint line_len;
- long response_code; /* long due to zend_parse_parameters compatibility */
+ zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
typedef enum { /* Parameter: */
@@ -197,10 +198,10 @@ SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry TSRMLS_DC);
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry TSRMLS_DC);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D) TSRMLS_DC);
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC) TSRMLS_DC);
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC);
+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 TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC);
SAPI_API int sapi_flush(TSRMLS_D);
-SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
+SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D);
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC);
SAPI_API char *sapi_get_default_content_type(TSRMLS_D);
@@ -227,9 +228,9 @@ struct _sapi_module_struct {
int (*activate)(TSRMLS_D);
int (*deactivate)(TSRMLS_D);
- int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC);
+ size_t (*ub_write)(const char *str, size_t str_length TSRMLS_DC);
void (*flush)(void *server_context TSRMLS_DC);
- struct stat *(*get_stat)(TSRMLS_D);
+ zend_stat_t *(*get_stat)(TSRMLS_D);
char *(*getenv)(char *name, size_t name_len TSRMLS_DC);
void (*sapi_error)(int type, const char *error_msg, ...);
@@ -238,7 +239,7 @@ struct _sapi_module_struct {
int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC);
- int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC);
+ size_t (*read_post)(char *buffer, size_t count_bytes TSRMLS_DC);
char *(*read_cookies)(TSRMLS_D);
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
@@ -265,7 +266,7 @@ struct _sapi_module_struct {
int (*get_target_uid)(uid_t * TSRMLS_DC);
int (*get_target_gid)(gid_t * TSRMLS_DC);
- unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
+ unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len TSRMLS_DC);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
@@ -299,7 +300,7 @@ struct _sapi_post_entry {
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg TSRMLS_DC)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray TSRMLS_DC)
-#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)
+#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 TSRMLS_DC)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 981c5c5a15..a4aa10fce8 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -94,24 +94,24 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN || stage == PHP_INI_STAGE_ACTIVATE || stage == PHP_INI_STAGE_DEACTIVATE) {
/* We're in a PHP_INI_SYSTEM context, no restrictions */
- *p = new_value;
+ *p = new_value ? new_value->val : NULL;
return SUCCESS;
}
/* Otherwise we're in runtime */
if (!*p || !**p) {
/* open_basedir not set yet, go ahead and give it a value */
- *p = new_value;
+ *p = new_value->val;
return SUCCESS;
}
/* Shortcut: When we have a open_basedir and someone tries to unset, we know it'll fail */
- if (!new_value || !*new_value) {
+ if (!new_value || !*new_value->val) {
return FAILURE;
}
/* Is the proposed open_basedir at least as restrictive as the current setting? */
- ptr = pathbuf = estrdup(new_value);
+ ptr = pathbuf = estrdup(new_value->val);
while (ptr && *ptr) {
end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
if (end != NULL) {
@@ -128,7 +128,7 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
efree(pathbuf);
/* Everything checks out, set it */
- *p = new_value;
+ *p = new_value->val;
return SUCCESS;
}
@@ -226,12 +226,13 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
/* Resolve open_basedir to resolved_basedir */
if (expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) != NULL) {
+ int basedir_len = (int)strlen(basedir);
/* Handler for basedirs that end with a / */
- resolved_basedir_len = strlen(resolved_basedir);
+ resolved_basedir_len = (int)strlen(resolved_basedir);
#if defined(PHP_WIN32) || defined(NETWARE)
- if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR || basedir[strlen(basedir) - 1] == '/') {
+ if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR || basedir[basedir_len - 1] == '/') {
#else
- if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR) {
+ if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR) {
#endif
if (resolved_basedir[resolved_basedir_len - 1] != PHP_DIR_SEPARATOR) {
resolved_basedir[resolved_basedir_len] = PHP_DIR_SEPARATOR;
@@ -758,10 +759,15 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
cwd_state new_state;
char cwd[MAXPATHLEN];
int copy_len;
+ int path_len;
if (!filepath[0]) {
return NULL;
- } else if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) {
+ }
+
+ path_len = (int)strlen(filepath);
+
+ if (IS_ABSOLUTE_PATH(filepath, path_len)) {
cwd[0] = '\0';
} else {
const char *iam = SG(request_info).path_translated;
@@ -784,7 +790,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
/* return a relative file path if for any reason
* we cannot cannot getcwd() and the requested,
* relatively referenced file is accessible */
- copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
+ copy_len = path_len > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : path_len;
if (real_path) {
memcpy(real_path, filepath, copy_len);
real_path[copy_len] = '\0';
diff --git a/main/main.c b/main/main.c
index 1fd314b582..fde2902d64 100644
--- a/main/main.c
+++ b/main/main.c
@@ -53,6 +53,7 @@
#include <locale.h>
#endif
#include "zend.h"
+#include "zend_types.h"
#include "zend_extensions.h"
#include "php_ini.h"
#include "php_globals.h"
@@ -160,7 +161,9 @@ static php_win32_disable_functions(TSRMLS_D)
*/
static PHP_INI_MH(OnSetPrecision)
{
- int i = atoi(new_value);
+ zend_long i;
+
+ ZEND_ATOL(i, new_value->val);
if (i >= 0) {
EG(precision) = i;
return SUCCESS;
@@ -175,7 +178,7 @@ static PHP_INI_MH(OnSetPrecision)
static PHP_INI_MH(OnChangeMemoryLimit)
{
if (new_value) {
- PG(memory_limit) = zend_atol(new_value, new_value_length);
+ PG(memory_limit) = zend_atol(new_value->val, new_value->len);
} else {
PG(memory_limit) = 1<<30; /* effectively, no limit */
}
@@ -279,7 +282,7 @@ static void php_binary_init(TSRMLS_D)
if ((envpath = getenv("PATH")) != NULL) {
char *search_dir, search_path[MAXPATHLEN];
char *last = NULL;
- struct stat s;
+ zend_stat_t s;
path = estrdup(envpath);
search_dir = php_strtok_r(path, ":", &last);
@@ -316,11 +319,11 @@ static PHP_INI_MH(OnUpdateTimeout)
{
if (stage==PHP_INI_STAGE_STARTUP) {
/* Don't set a timeout on startup, only per-request */
- EG(timeout_seconds) = atoi(new_value);
+ ZEND_ATOL(EG(timeout_seconds), new_value->val);
return SUCCESS;
}
zend_unset_timeout(TSRMLS_C);
- EG(timeout_seconds) = atoi(new_value);
+ ZEND_ATOL(EG(timeout_seconds), new_value->val);
zend_set_timeout(EG(timeout_seconds), 0);
return SUCCESS;
}
@@ -347,7 +350,7 @@ static int php_get_display_errors_mode(char *value, int value_length)
} else if (value_length == 6 && !strcasecmp(value, "stdout")) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
} else {
- mode = atoi(value);
+ ZEND_ATOL(mode, value);
if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
}
@@ -361,7 +364,7 @@ static int php_get_display_errors_mode(char *value, int value_length)
*/
static PHP_INI_MH(OnUpdateDisplayErrors)
{
- PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length);
+ PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value->val, new_value->len);
return SUCCESS;
}
@@ -376,11 +379,11 @@ static PHP_INI_DISP(display_errors_mode)
TSRMLS_FETCH();
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
- tmp_value_length = ini_entry->orig_value_length;
+ tmp_value = (ini_entry->orig_value ? ini_entry->orig_value->val : NULL );
+ tmp_value_length = ini_entry->orig_value->len;
} else if (ini_entry->value) {
- tmp_value = ini_entry->value;
- tmp_value_length = ini_entry->value_length;
+ tmp_value = ini_entry->value->val;
+ tmp_value_length = ini_entry->value->len;
} else {
tmp_value = NULL;
tmp_value_length = 0;
@@ -420,9 +423,9 @@ static PHP_INI_DISP(display_errors_mode)
static PHP_INI_MH(OnUpdateInternalEncoding)
{
if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
} else {
- OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ PG(internal_encoding) = SG(default_charset);
}
return SUCCESS;
}
@@ -433,9 +436,9 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
static PHP_INI_MH(OnUpdateInputEncoding)
{
if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
} else {
- OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ PG(input_encoding) = SG(default_charset);
}
return SUCCESS;
}
@@ -446,9 +449,9 @@ static PHP_INI_MH(OnUpdateInputEncoding)
static PHP_INI_MH(OnUpdateOutputEncoding)
{
if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
} else {
- OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ PG(output_encoding) = SG(default_charset);
}
return SUCCESS;
}
@@ -459,12 +462,12 @@ static PHP_INI_MH(OnUpdateOutputEncoding)
static PHP_INI_MH(OnUpdateErrorLog)
{
/* Only do the safemode/open_basedir check at runtime */
- if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value && strcmp(new_value, "syslog")) {
- if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {
+ if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value && strcmp(new_value->val, "syslog")) {
+ if (PG(open_basedir) && php_check_open_basedir(new_value->val TSRMLS_CC)) {
return FAILURE;
}
}
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
return SUCCESS;
}
/* }}} */
@@ -475,11 +478,11 @@ static PHP_INI_MH(OnUpdateMailLog)
{
/* Only do the safemode/open_basedir check at runtime */
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value) {
- if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {
+ if (PG(open_basedir) && php_check_open_basedir(new_value->val TSRMLS_CC)) {
return FAILURE;
}
}
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
return SUCCESS;
}
/* }}} */
@@ -689,7 +692,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
#endif
php_ignore_value(write(fd, tmp, len));
efree(tmp);
- STR_FREE(error_time_str);
+ zend_string_free(error_time_str);
close(fd);
PG(in_error_log) = 0;
return;
@@ -707,7 +710,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
/* {{{ php_write
wrapper for modules to use PHPWRITE */
-PHPAPI int php_write(void *buf, uint size TSRMLS_DC)
+PHPAPI size_t php_write(void *buf, size_t size TSRMLS_DC)
{
return PHPWRITE(buf, size);
}
@@ -715,12 +718,12 @@ PHPAPI int php_write(void *buf, uint size TSRMLS_DC)
/* {{{ php_printf
*/
-PHPAPI int php_printf(const char *format, ...)
+PHPAPI size_t php_printf(const char *format, ...)
{
va_list args;
- int ret;
+ size_t ret;
char *buffer;
- int size;
+ size_t size;
TSRMLS_FETCH();
va_start(args, format);
@@ -891,7 +894,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
spprintf(&message, 0, "%s: %s", origin, buffer);
}
if (replace_origin) {
- STR_FREE(replace_origin);
+ zend_string_free(replace_origin);
} else {
efree(origin);
}
@@ -912,7 +915,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
}
}
if (replace_buffer) {
- STR_FREE(replace_buffer);
+ zend_string_free(replace_buffer);
} else {
efree(buffer);
}
@@ -1127,7 +1130,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) {
if (PG(xmlrpc_errors)) {
- php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno);
+ php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%pd</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno);
} else {
char *prepend_string = INI_STR("error_prepend_string");
char *append_string = INI_STR("error_append_string");
@@ -1136,7 +1139,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
if (type == E_ERROR || type == E_PARSE) {
zend_string *buf = php_escape_html_entities(buffer, buffer_len, 0, ENT_COMPAT, NULL TSRMLS_CC);
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf->val, error_filename, error_lineno, STR_PRINT(append_string));
- STR_FREE(buf);
+ zend_string_free(buf);
} else {
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
}
@@ -1263,7 +1266,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
*/
PHPAPI char *php_get_current_user(TSRMLS_D)
{
- struct stat *pstat;
+ zend_stat_t *pstat;
if (SG(request_info).current_user) {
return SG(request_info).current_user;
@@ -1326,7 +1329,7 @@ PHPAPI char *php_get_current_user(TSRMLS_D)
Sets the maximum time a script can run */
PHP_FUNCTION(set_time_limit)
{
- long new_timeout;
+ zend_long new_timeout;
char *new_timeout_str;
int new_timeout_strlen;
zend_string *key;
@@ -1335,15 +1338,15 @@ PHP_FUNCTION(set_time_limit)
return;
}
- new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, "%ld", new_timeout);
+ new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
- key = STR_INIT("max_execution_time", sizeof("max_execution_time")-1, 0);
- if (zend_alter_ini_entry_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == SUCCESS) {
+ key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0);
+ if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == SUCCESS) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
- STR_RELEASE(key);
+ zend_string_release(key);
efree(new_timeout_str);
}
/* }}} */
@@ -1436,22 +1439,15 @@ static char *php_resolve_path_for_zend(const char *filename, int filename_len TS
/* {{{ php_get_configuration_directive_for_zend
*/
-static int php_get_configuration_directive_for_zend(const char *name, uint name_length, zval *contents)
+static zval *php_get_configuration_directive_for_zend(zend_string *name)
{
- zval *retval = cfg_get_entry(name, name_length);
-
- if (retval) {
- *contents = *retval;
- return SUCCESS;
- } else {
- return FAILURE;
- }
+ return cfg_get_entry_ex(name);
}
/* }}} */
/* {{{ php_message_handler_for_zend
*/
-static void php_message_handler_for_zend(long message, const void *data TSRMLS_DC)
+static void php_message_handler_for_zend(zend_long message, const void *data TSRMLS_DC)
{
switch (message) {
case ZMSG_FAILED_INCLUDE_FOPEN:
@@ -1497,7 +1493,7 @@ static void php_message_handler_for_zend(long message, const void *data TSRMLS_D
if (EG(error_reporting) & E_WARNING) {
char memory_leak_buf[512];
- snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((zend_uint *) data));
+ snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((uint32_t *) data));
# if defined(PHP_WIN32)
OutputDebugString(memory_leak_buf);
# else
@@ -1921,7 +1917,7 @@ PHPAPI void php_com_initialize(TSRMLS_D)
/* {{{ php_output_wrapper
*/
-static int php_output_wrapper(const char *str, uint str_length)
+static size_t php_output_wrapper(const char *str, size_t str_length)
{
TSRMLS_FETCH();
return php_output_write(str, str_length TSRMLS_CC);
@@ -2209,9 +2205,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", LONG_MIN, CONST_PERSISTENT | CONST_CS);
- REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", ZEND_LONG_MAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", ZEND_LONG_MIN, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_LONG, CONST_PERSISTENT | CONST_CS);
#ifdef PHP_WIN32
REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS);
@@ -2372,7 +2368,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
const char **p = directives[i].directives;
while(*p) {
- long value;
+ zend_long value;
if (cfg_get_long((char*)*p, &value) == SUCCESS && value) {
zend_error(directives[i].error_level, directives[i].phrase, *p);
@@ -2651,7 +2647,7 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC)
SG(request_info).auth_password = estrdup(pass);
ret = 0;
}
- STR_FREE(user);
+ zend_string_free(user);
}
}
diff --git a/main/network.c b/main/network.c
index 366e52c90b..0b018c2e87 100644
--- a/main/network.c
+++ b/main/network.c
@@ -507,7 +507,7 @@ bound:
}
/* }}} */
-PHPAPI int php_network_parse_network_address_with_port(const char *addr, long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC)
+PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC)
{
char *colon;
char *tmp;
@@ -563,7 +563,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, long ad
if (n == 0) {
if (errstr) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to resolve `%s': %s", tmp, errstr->val);
- STR_RELEASE(errstr);
+ zend_string_release(errstr);
}
goto out;
}
@@ -645,10 +645,10 @@ PHPAPI void php_network_populate_name_from_sockaddr(
if (ua->sun_path[0] == '\0') {
/* abstract name */
int len = strlen(ua->sun_path + 1) + 1;
- *textaddr = STR_INIT((char*)ua->sun_path, len, 0);
+ *textaddr = zend_string_init((char*)ua->sun_path, len, 0);
} else {
int len = strlen(ua->sun_path);
- *textaddr = STR_INIT((char*)ua->sun_path, len, 0);
+ *textaddr = zend_string_init((char*)ua->sun_path, len, 0);
}
}
break;
@@ -880,7 +880,7 @@ skip_bind:
}
/* free error string received during previous iteration (if any) */
if (error_string && *error_string) {
- STR_RELEASE(*error_string);
+ zend_string_release(*error_string);
*error_string = NULL;
}
@@ -1050,7 +1050,7 @@ PHPAPI zend_string *php_socket_error_str(long err)
char *errstr;
errstr = strerror(err);
- return STR_INIT(errstr, strlen(errstr), 0);
+ return zend_string_init(errstr, strlen(errstr), 0);
#else
zend_string *ret;
char *sysbuf;
@@ -1070,7 +1070,7 @@ PHPAPI zend_string *php_socket_error_str(long err)
sysbuf = "Unknown Error";
}
- ret = STR_INIT(sysbuf, strlen(sysbuf), 0);
+ ret = zend_string_init(sysbuf, strlen(sysbuf), 0);
if (free_it) {
LocalFree(sysbuf);
@@ -1110,7 +1110,7 @@ PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short p
int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC TSRMLS_DC)
{
char *res;
- long reslen;
+ zend_long reslen;
php_stream *stream;
reslen = spprintf(&res, 0, "tcp://%s:%d", host, port);
diff --git a/main/output.c b/main/output.c
index 41b2c65cdf..b51892c140 100644
--- a/main/output.c
+++ b/main/output.c
@@ -519,7 +519,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,
efree(error);
}
if (handler_name) {
- STR_RELEASE(handler_name);
+ zend_string_release(handler_name);
}
}
@@ -532,11 +532,11 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,
PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t output_handler, size_t chunk_size, int flags TSRMLS_DC)
{
php_output_handler *handler;
- zend_string *str = STR_INIT(name, name_len, 1);
+ zend_string *str = zend_string_init(name, name_len, 1);
handler = php_output_handler_init(str, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL TSRMLS_CC);
handler->func.internal = output_handler;
- STR_RELEASE(str);
+ zend_string_release(str);
return handler;
}
@@ -718,7 +718,7 @@ PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg TSR
PHPAPI void php_output_handler_dtor(php_output_handler *handler TSRMLS_DC)
{
if (handler->name) {
- STR_RELEASE(handler->name);
+ zend_string_release(handler->name);
}
if (handler->buffer.data) {
efree(handler->buffer.data);
@@ -885,7 +885,7 @@ static inline php_output_handler *php_output_handler_init(zend_string *name, siz
php_output_handler *handler;
handler = ecalloc(1, sizeof(php_output_handler));
- handler->name = STR_COPY(name);
+ handler->name = zend_string_copy(name);
handler->size = chunk_size;
handler->flags = flags;
handler->buffer.size = PHP_OUTPUT_HANDLER_INITBUF_SIZE(chunk_size);
@@ -973,7 +973,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
zval retval, ob_data, ob_mode;
ZVAL_STRINGL(&ob_data, handler->buffer.data, handler->buffer.used);
- ZVAL_LONG(&ob_mode, (long) context->op);
+ ZVAL_LONG(&ob_mode, (zend_long) context->op);
zend_fcall_info_argn(&handler->func.user->fci TSRMLS_CC, 2, &ob_data, &ob_mode);
#define PHP_OUTPUT_USER_SUCCESS(retval) ((Z_TYPE(retval) != IS_UNDEF) && !(Z_TYPE(retval) == IS_FALSE))
@@ -1172,7 +1172,7 @@ static int php_output_stack_apply_list(void *h, void *z)
php_output_handler *handler = *(php_output_handler **) h;
zval *array = (zval *) z;
- add_next_index_str(array, STR_COPY(handler->name));
+ add_next_index_str(array, zend_string_copy(handler->name));
return 0;
}
/* }}} */
@@ -1196,13 +1196,13 @@ static inline zval *php_output_handler_status(php_output_handler *handler, zval
ZEND_ASSERT(entry != NULL);
array_init(entry);
- add_assoc_str(entry, "name", STR_COPY(handler->name));
- add_assoc_long(entry, "type", (long) (handler->flags & 0xf));
- add_assoc_long(entry, "flags", (long) handler->flags);
- add_assoc_long(entry, "level", (long) handler->level);
- add_assoc_long(entry, "chunk_size", (long) handler->size);
- add_assoc_long(entry, "buffer_size", (long) handler->buffer.size);
- add_assoc_long(entry, "buffer_used", (long) handler->buffer.used);
+ add_assoc_str(entry, "name", zend_string_copy(handler->name));
+ add_assoc_long(entry, "type", (zend_long) (handler->flags & 0xf));
+ add_assoc_long(entry, "flags", (zend_long) handler->flags);
+ add_assoc_long(entry, "level", (zend_long) handler->level);
+ add_assoc_long(entry, "chunk_size", (zend_long) handler->size);
+ add_assoc_long(entry, "buffer_size", (zend_long) handler->buffer.size);
+ add_assoc_long(entry, "buffer_used", (zend_long) handler->buffer.used);
return entry;
}
@@ -1316,8 +1316,8 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
PHP_FUNCTION(ob_start)
{
zval *output_handler = NULL;
- long chunk_size = 0;
- long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
+ zend_long chunk_size = 0;
+ zend_long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags) == FAILURE) {
return;
@@ -1539,7 +1539,7 @@ PHP_FUNCTION(ob_get_status)
Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)
{
- long flag = 1;
+ zend_long flag = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
return;
@@ -1566,7 +1566,7 @@ PHP_FUNCTION(output_reset_rewrite_vars)
PHP_FUNCTION(output_add_rewrite_var)
{
char *name, *value;
- int name_len, value_len;
+ size_t name_len, value_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) {
return;
diff --git a/main/php.h b/main/php.h
index f9cfd2d7f2..11a8a64401 100644
--- a/main/php.h
+++ b/main/php.h
@@ -280,8 +280,8 @@ ssize_t pread(int, void *, size_t, off64_t);
BEGIN_EXTERN_C()
void phperror(char *error);
-PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
-PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
+PHPAPI size_t php_write(void *buf, size_t size TSRMLS_DC);
+PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
2);
PHPAPI int php_get_module_initialized(void);
PHPAPI void php_log_err(char *log_message TSRMLS_DC);
@@ -434,7 +434,7 @@ END_EXTERN_C()
#else /* ! (CRAY || __arm) */
#define XtOffset(p_type, field) \
- ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+ ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
#endif /* !CRAY */
#endif /* ! XtOffset */
diff --git a/main/php_globals.h b/main/php_globals.h
index 9baabf757c..14d0a03868 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -56,7 +56,7 @@ typedef struct _arg_separators {
struct _php_core_globals {
zend_bool implicit_flush;
- long output_buffering;
+ zend_long output_buffering;
zend_bool sql_safe_mode;
zend_bool enable_dl;
@@ -64,16 +64,16 @@ struct _php_core_globals {
char *output_handler;
char *unserialize_callback_func;
- long serialize_precision;
+ zend_long serialize_precision;
- long memory_limit;
- long max_input_time;
+ zend_long memory_limit;
+ zend_long max_input_time;
zend_bool track_errors;
zend_bool display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
- long log_errors_max_len;
+ zend_long log_errors_max_len;
zend_bool ignore_repeated_errors;
zend_bool ignore_repeated_source;
zend_bool report_memleaks;
@@ -88,7 +88,7 @@ struct _php_core_globals {
char *sys_temp_dir;
char *upload_tmp_dir;
- long upload_max_filesize;
+ zend_long upload_max_filesize;
char *error_append_string;
char *error_prepend_string;
@@ -126,7 +126,7 @@ struct _php_core_globals {
zend_bool html_errors;
zend_bool xmlrpc_errors;
- long xmlrpc_error_number;
+ zend_long xmlrpc_error_number;
zend_bool activated_auto_globals[8];
@@ -149,12 +149,12 @@ struct _php_core_globals {
#ifdef PHP_WIN32
zend_bool com_initialized;
#endif
- long max_input_nesting_level;
- long max_input_vars;
+ zend_long max_input_nesting_level;
+ zend_long max_input_vars;
zend_bool in_user_include;
char *user_ini_filename;
- long user_ini_cache_ttl;
+ zend_long user_ini_cache_ttl;
char *request_order;
diff --git a/main/php_ini.c b/main/php_ini.c
index cdd4a61fb5..b3dcd3e546 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -83,9 +83,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
uint display_string_length, esc_html=0;
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- if (ini_entry->orig_value && ini_entry->orig_value[0]) {
- display_string = ini_entry->orig_value;
- display_string_length = ini_entry->orig_value_length;
+ if (ini_entry->orig_value && ini_entry->orig_value->val[0]) {
+ display_string = ini_entry->orig_value->val;
+ display_string_length = ini_entry->orig_value->len;
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -96,9 +96,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC)
display_string_length = sizeof("no value") - 1;
}
}
- } else if (ini_entry->value && ini_entry->value[0]) {
- display_string = ini_entry->value;
- display_string_length = ini_entry->value_length;
+ } else if (ini_entry->value && ini_entry->value->val[0]) {
+ display_string = ini_entry->value->val;
+ display_string_length = ini_entry->value->len;
esc_html = !sapi_module.phpinfo_as_text;
} else {
if (!sapi_module.phpinfo_as_text) {
@@ -132,14 +132,14 @@ static int php_ini_displayer(zval *el, void *arg TSRMLS_DC)
if (!sapi_module.phpinfo_as_text) {
PUTS("<tr>");
PUTS("<td class=\"e\">");
- PHPWRITE(ini_entry->name, ini_entry->name_length);
+ PHPWRITE(ini_entry->name->val, ini_entry->name->len);
PUTS("</td><td class=\"v\">");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
PUTS("</td><td class=\"v\">");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC);
PUTS("</td></tr>\n");
} else {
- PHPWRITE(ini_entry->name, ini_entry->name_length);
+ PHPWRITE(ini_entry->name->val, ini_entry->name->len);
PUTS(" => ");
php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC);
PUTS(" => ");
@@ -200,7 +200,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
zend_hash_destroy(Z_ARRVAL_P(zvalue));
free(Z_ARR_P(zvalue));
} else if (Z_TYPE_P(zvalue) == IS_STRING) {
- STR_RELEASE(Z_STR_P(zvalue));
+ zend_string_release(Z_STR_P(zvalue));
}
}
/* Reset / free active_ini_sectin global */
@@ -243,7 +243,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
} else {
/* Store in active hash */
entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2);
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
}
break;
@@ -272,7 +272,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
} else {
entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2);
}
- Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1);
+ Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1);
}
break;
@@ -545,7 +545,7 @@ int php_init_config(TSRMLS_D)
/* Check if php_ini_file_name is a file and can be opened */
if (php_ini_file_name && php_ini_file_name[0]) {
- struct stat statbuf;
+ zend_stat_t statbuf;
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
@@ -593,7 +593,7 @@ int php_init_config(TSRMLS_D)
{
zval tmp;
- ZVAL_NEW_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1));
+ ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
if (php_ini_opened_path) {
efree(php_ini_opened_path);
@@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D)
if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
struct dirent **namelist;
int ndir, i;
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
char *p;
zend_file_handle fh2;
@@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D)
*/
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC)
{
- struct stat sb;
+ zend_stat_t sb;
char ini_file[MAXPATHLEN];
zend_file_handle fh;
@@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
{
zend_string *str;
zval *data;
- ulong num_index;
+ zend_ulong num_index;
/* Walk through config hash and alter matching ini entries using the values found in the hash */
for (zend_hash_internal_pointer_reset(source_hash);
@@ -786,7 +786,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
zend_hash_move_forward(source_hash)
) {
data = zend_hash_get_current_data(source_hash);
- zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC);
+ zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0 TSRMLS_CC);
}
}
/* }}} */
@@ -867,6 +867,14 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR
/* {{{ cfg_get_entry
*/
+PHPAPI zval *cfg_get_entry_ex(zend_string *name)
+{
+ return zend_hash_find(&configuration_hash, name);
+}
+/* }}} */
+
+/* {{{ cfg_get_entry
+ */
PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
{
return zend_hash_str_find(&configuration_hash, name, name_length);
@@ -875,7 +883,7 @@ PHPAPI zval *cfg_get_entry(const char *name, uint name_length)
/* {{{ cfg_get_long
*/
-PHPAPI int cfg_get_long(const char *varname, long *result)
+PHPAPI int cfg_get_long(const char *varname, zend_long *result)
{
zval *tmp, var;
diff --git a/main/php_ini.h b/main/php_ini.h
index 4159e7591f..2e118d14e3 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -28,8 +28,9 @@ PHPAPI void config_zval_dtor(zval *zvalue);
int php_init_config(TSRMLS_D);
int php_shutdown_config(void);
void php_ini_register_extensions(TSRMLS_D);
+PHPAPI zval *cfg_get_entry_ex(zend_string *name);
PHPAPI zval *cfg_get_entry(const char *name, uint name_length);
-PHPAPI int cfg_get_long(const char *varname, long *result);
+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 TSRMLS_DC);
diff --git a/main/php_network.h b/main/php_network.h
index 3a0062c437..1528447c73 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -306,7 +306,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
TSRMLS_DC);
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
- long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC);
+ zend_long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC);
END_EXTERN_C()
#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC TSRMLS_CC)
diff --git a/main/php_output.h b/main/php_output.h
index f8b961c7c3..2fbc088d05 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -143,12 +143,12 @@ typedef struct _php_output_handler {
} php_output_handler;
ZEND_BEGIN_MODULE_GLOBALS(output)
- int flags;
zend_stack handlers;
php_output_handler *active;
php_output_handler *running;
const char *output_start_filename;
int output_start_lineno;
+ int flags;
ZEND_END_MODULE_GLOBALS(output)
/* there should not be a need to use OG() from outside of output.c */
diff --git a/main/php_stdint.h b/main/php_stdint.h
index 14b32d7ca4..527ee3493d 100644
--- a/main/php_stdint.h
+++ b/main/php_stdint.h
@@ -28,6 +28,7 @@
# if !defined(_STDINT)
# define _STDINT
# include "win32/php_stdint.h"
+# include "win32/php_inttypes.h"
# endif
# define HAVE_INT8_T 1
# define HAVE_UINT8_T 1
diff --git a/main/php_streams.h b/main/php_streams.h
index 38215a67b0..9a6e84dfe6 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -26,6 +26,8 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#include "zend.h"
+#include "zend_stream.h"
BEGIN_EXTERN_C()
PHPAPI int php_file_le_stream(void);
@@ -104,7 +106,7 @@ typedef struct _php_stream_filter php_stream_filter;
#include "streams/php_stream_filter_api.h"
typedef struct _php_stream_statbuf {
- struct stat sb; /* regular info */
+ zend_stat_t sb; /* regular info */
/* extended info to go here some day: content-type etc. etc. */
} php_stream_statbuf;
@@ -123,7 +125,7 @@ typedef struct _php_stream_ops {
const char *label; /* label for this ops structure */
/* these are optional */
- int (*seek)(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+ int (*seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC);
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
@@ -209,11 +211,11 @@ struct _php_stream {
int flags; /* PHP_STREAM_FLAG_XXX */
/* buffer */
- off_t position; /* of underlying stream */
+ zend_off_t position; /* of underlying stream */
unsigned char *readbuf;
size_t readbuflen;
- off_t readpos;
- off_t writepos;
+ zend_off_t readpos;
+ zend_off_t writepos;
/* how much data to read when filling buffer */
size_t chunk_size;
@@ -279,11 +281,11 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC);
#define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC)
#define php_stream_pclose(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE_PERSISTENT TSRMLS_CC)
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC);
+PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC);
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET TSRMLS_CC)
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence) TSRMLS_CC)
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
+PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
#define php_stream_tell(stream) _php_stream_tell((stream) TSRMLS_CC)
PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
@@ -293,6 +295,9 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str) TSRMLS_CC)
#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count) TSRMLS_CC)
+PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC);
+#define php_stream_fill_read_buffer(stream, size) _php_stream_fill_read_buffer((stream), (size) TSRMLS_CC)
+
#ifdef ZTS
PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
#else
diff --git a/main/php_variables.c b/main/php_variables.c
index 3bb6d65aa5..0f16b92d02 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -43,13 +43,13 @@ PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_arra
}
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zval *track_vars_array TSRMLS_DC)
+PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array TSRMLS_DC)
{
zval new_entry;
assert(strval != NULL);
/* Prepare value */
- ZVAL_NEW_STR(&new_entry, STR_INIT(strval, str_len, 0));
+ ZVAL_NEW_STR(&new_entry, zend_string_init(strval, str_len, 0));
php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC);
}
@@ -141,7 +141,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
/* do not output the error message to the screen,
this helps us to to avoid "information disclosure" */
if (!PG(display_errors)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
}
free_alloca(var_orig, use_heap);
return;
@@ -243,10 +243,10 @@ typedef struct post_var_data {
static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSRMLS_DC)
{
- char *ksep, *vsep;
+ char *ksep, *vsep, *val;
size_t klen, vlen;
/* FIXME: string-size_t */
- unsigned int new_vlen;
+ size_t new_vlen;
if (var->ptr >= var->end) {
return 0;
@@ -274,15 +274,17 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
vlen = 0;
}
-
php_url_decode(var->ptr, klen);
+
+ val = estrndup(ksep, vlen);
if (vlen) {
- vlen = php_url_decode(ksep, vlen);
+ vlen = php_url_decode(val, vlen);
}
- if (sapi_module.input_filter(PARSE_POST, var->ptr, &ksep, vlen, &new_vlen TSRMLS_CC)) {
- php_register_variable_safe(var->ptr, ksep, new_vlen, arr TSRMLS_CC);
+ if (sapi_module.input_filter(PARSE_POST, var->ptr, &val, vlen, &new_vlen TSRMLS_CC)) {
+ php_register_variable_safe(var->ptr, val, new_vlen, arr TSRMLS_CC);
}
+ efree(val);
var->ptr = vsep + (vsep != var->end);
return 1;
@@ -358,7 +360,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
zval array;
int free_buffer = 0;
char *strtok_buf = NULL;
- long count = 0;
+ zend_long count = 0;
ZVAL_UNDEF(&array);
switch (arg) {
@@ -442,13 +444,13 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
}
if (++count > PG(max_input_vars)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
break;
}
if (val) { /* have a value */
- int val_len;
- unsigned int new_val_len;
+ size_t val_len;
+ size_t new_val_len;
*val++ = '\0';
php_url_decode(var, strlen(var));
@@ -459,8 +461,8 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
}
efree(val);
} else {
- int val_len;
- unsigned int new_val_len;
+ size_t val_len;
+ size_t new_val_len;
php_url_decode(var, strlen(var));
val_len = 0;
@@ -535,7 +537,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
for (i = 0; i < SG(request_info).argc; i++) {
ZVAL_STRING(&tmp, SG(request_info).argv[i]);
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- STR_FREE(Z_STR(tmp));
+ zend_string_free(Z_STR(tmp));
}
}
} else if (s && *s) {
@@ -549,7 +551,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
ZVAL_STRING(&tmp, ss);
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
- STR_FREE(Z_STR(tmp));
+ zend_string_free(Z_STR(tmp));
}
if (space) {
*space = '+';
@@ -621,7 +623,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
{
zval *src_entry, *dest_entry;
zend_string *string_key;
- ulong num_key;
+ zend_ulong num_key;
int globals_check = (dest == (&EG(symbol_table).ht));
ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) {
@@ -816,13 +818,13 @@ static zend_bool php_auto_globals_create_request(zend_string *name TSRMLS_DC)
void php_startup_auto_globals(TSRMLS_D)
{
- zend_register_auto_global(STR_INIT("_GET", sizeof("_GET")-1, 1), 0, php_auto_globals_create_get TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_POST", sizeof("_POST")-1, 1), 0, php_auto_globals_create_post TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_COOKIE", sizeof("_COOKIE")-1, 1), 0, php_auto_globals_create_cookie TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_SERVER", sizeof("_SERVER")-1, 1), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_ENV", sizeof("_ENV")-1, 1), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_REQUEST", sizeof("_REQUEST")-1, 1), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
- zend_register_auto_global(STR_INIT("_FILES", sizeof("_FILES")-1, 1), 0, php_auto_globals_create_files TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_GET", sizeof("_GET")-1, 1), 0, php_auto_globals_create_get TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_POST", sizeof("_POST")-1, 1), 0, php_auto_globals_create_post TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_COOKIE", sizeof("_COOKIE")-1, 1), 0, php_auto_globals_create_cookie TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_SERVER", sizeof("_SERVER")-1, 1), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_ENV", sizeof("_ENV")-1, 1), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_REQUEST", sizeof("_REQUEST")-1, 1), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
+ zend_register_auto_global(zend_string_init("_FILES", sizeof("_FILES")-1, 1), 0, php_auto_globals_create_files TSRMLS_CC);
}
/*
diff --git a/main/php_variables.h b/main/php_variables.h
index 2331c582e6..70f5e1dc7f 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -38,7 +38,7 @@ void php_startup_auto_globals(TSRMLS_D);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr TSRMLS_DC);
PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array TSRMLS_DC);
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *val, int val_len, zval *track_vars_array TSRMLS_DC);
+PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array TSRMLS_DC);
PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array TSRMLS_DC);
PHPAPI int php_hash_environment(TSRMLS_D);
diff --git a/main/php_version.h b/main/php_version.h
index d48ab24141..186d9d2b7d 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -6,3 +6,4 @@
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "7.0.0-dev"
#define PHP_VERSION_ID 70000
+
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 3347a69ac8..0f2941ef98 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -58,7 +58,7 @@ static php_rfc1867_basename_t php_rfc1867_basename = NULL;
PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC) = NULL;
-static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);
+static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC);
/* The longest property name we use in an uploaded file array */
#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
@@ -161,7 +161,7 @@ static zend_bool is_protected_variable(char *varname TSRMLS_DC) /* {{{ */
}
/* }}} */
-static void safe_php_register_variable(char *var, char *strval, int val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
+static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, zend_bool override_protection TSRMLS_DC) /* {{{ */
{
if (override_protection || !is_protected_variable(var TSRMLS_CC)) {
php_register_variable_safe(var, strval, val_len, track_vars_array TSRMLS_CC);
@@ -611,9 +611,9 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne
}
/* read until a boundary condition */
-static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, int *end TSRMLS_DC)
+static int multipart_buffer_read(multipart_buffer *self, char *buf, size_t bytes, int *end TSRMLS_DC)
{
- int len, max;
+ size_t len, max;
char *bound;
/* fill buffer if needed */
@@ -657,7 +657,7 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, i
XXX: this is horrible memory-usage-wise, but we only expect
to do this on small pieces of form data.
*/
-static char *multipart_buffer_read_body(multipart_buffer *self, unsigned int *len TSRMLS_DC)
+static char *multipart_buffer_read_body(multipart_buffer *self, size_t *len TSRMLS_DC)
{
char buf[FILLUNIT], *out=NULL;
int total_bytes=0, read_bytes=0;
@@ -701,7 +701,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
php_rfc1867_getword_t getword;
php_rfc1867_getword_conf_t getword_conf;
php_rfc1867_basename_t _basename;
- long count = 0;
+ zend_long count = 0;
if (php_rfc1867_encoding_translation(TSRMLS_C) && internal_encoding) {
getword = php_rfc1867_getword;
@@ -714,7 +714,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}
if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) {
- sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size));
+ sapi_module.sapi_error(E_WARNING, "POST Content-Length of " ZEND_LONG_FMT " bytes exceeds the limit of " ZEND_LONG_FMT " bytes", SG(request_info).content_length, SG(post_max_size));
return;
}
@@ -787,7 +787,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
char buff[FILLUNIT];
char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL;
size_t blen = 0, wlen = 0;
- off_t offset;
+ zend_off_t offset;
zend_llist_clean(&header);
@@ -850,9 +850,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
/* Normal form variable, safe to read all data into memory */
if (!filename && param) {
- unsigned int value_len;
+ size_t value_len;
char *value = multipart_buffer_read_body(mbuff, &value_len TSRMLS_CC);
- unsigned int new_val_len; /* Dummy variable */
+ size_t new_val_len; /* Dummy variable */
if (!value) {
value = estrdup("");
@@ -889,7 +889,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC);
} else {
if (count == PG(max_input_vars) + 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_LONG_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
}
if (php_rfc1867_callback != NULL) {
@@ -1034,14 +1034,14 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}
}
- if (PG(upload_max_filesize) > 0 && (long)(total_bytes+blen) > PG(upload_max_filesize)) {
+ if (PG(upload_max_filesize) > 0 && (zend_long)(total_bytes+blen) > PG(upload_max_filesize)) {
#if DEBUG_FILE_UPLOAD
- sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
+ sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of " ZEND_LONG_FMT " bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename);
#endif
cancel_upload = UPLOAD_ERROR_A;
- } else if (max_file_size && ((long)(total_bytes+blen) > max_file_size)) {
+ } else if (max_file_size && ((zend_long)(total_bytes+blen) > max_file_size)) {
#if DEBUG_FILE_UPLOAD
- sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
+ sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of " ZEND_LONG_FMT " bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename);
#endif
cancel_upload = UPLOAD_ERROR_B;
} else if (blen > 0) {
@@ -1230,7 +1230,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
if (cancel_upload) {
ZVAL_LONG(&file_size, 0);
} else {
- if (total_bytes > LONG_MAX) {
+ if (total_bytes > ZEND_LONG_MAX) {
#ifdef PHP_WIN32
if (_i64toa_s(total_bytes, file_size_buf, 65, 10)) {
file_size_buf[0] = '0';
diff --git a/main/rfc1867.h b/main/rfc1867.h
index 1d47165851..b76e3598f5 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -51,7 +51,7 @@ typedef struct _multipart_event_file_start {
typedef struct _multipart_event_file_data {
size_t post_bytes_processed;
- off_t offset;
+ zend_off_t offset;
char *data;
size_t length;
size_t *newlength;
diff --git a/main/snprintf.c b/main/snprintf.c
index 914cac7133..0675538ac5 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -312,7 +312,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
*/
/* char * ap_php_conv_10() {{{ */
char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len)
+ register bool_int * is_negative, char *buf_end, register size_t *len)
{
register char *p = buf_end;
register u_wide_int magnitude;
@@ -370,7 +370,7 @@ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
*/
/* PHPAPI char * php_conv_fp() {{{ */
PHPAPI char * php_conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len)
+ boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len)
{
register char *s = buf;
register char *p, *p_orig;
@@ -438,7 +438,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
if (format != 'F') {
char temp[EXPONENT_LENGTH]; /* for exponent conversion */
- int t_len;
+ size_t t_len;
bool_int exponent_is_negative;
*s++ = format; /* either e or E */
@@ -474,7 +474,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
* which is a pointer to the END of the buffer + 1 (i.e. if the buffer
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
-char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) /* {{{ */
+char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register size_t *len) /* {{{ */
{
register int mask = (1 << nbits) - 1;
register char *p = buf_end;
@@ -584,10 +584,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
char *sp;
char *bep;
int cc = 0;
- int i;
+ size_t i;
char *s = NULL;
- int s_len, free_zcopy;
+ size_t s_len;
+ int free_zcopy;
zval *zvp, zcopy;
int min_width = 0;
@@ -758,6 +759,10 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
modifier = LM_SIZE_T;
#endif
break;
+ case 'p':
+ fmt++;
+ modifier = LM_PHP_INT_T;
+ break;
case 'h':
fmt++;
if (*fmt == 'h') {
@@ -823,6 +828,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_ulong);
+ break;
}
/*
* The rest also applies to other integer formats, so fall
@@ -865,6 +873,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_long);
+ break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -911,6 +922,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
@@ -950,6 +964,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
diff --git a/main/snprintf.h b/main/snprintf.h
index 10f0e24fa5..6cef41f3f4 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -87,7 +87,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...);
PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_conv_fp(register char format, register double num,
- boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len);
+ boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, size_t *len);
END_EXTERN_C()
@@ -137,7 +137,8 @@ typedef enum {
#endif
LM_SIZE_T,
LM_LONG,
- LM_LONG_DOUBLE
+ LM_LONG_DOUBLE,
+ LM_PHP_INT_T
} length_modifier_e;
#ifdef PHP_WIN32
@@ -153,10 +154,10 @@ typedef WIDE_INT wide_int;
typedef unsigned WIDE_INT u_wide_int;
extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
- register bool_int * is_negative, char *buf_end, register int *len);
+ register bool_int * is_negative, char *buf_end, register size_t *len);
extern char * ap_php_conv_p2(register u_wide_int num, register int nbits,
- char format, char *buf_end, register int *len);
+ char format, char *buf_end, register size_t *len);
/* The maximum precision that's allowed for float conversion. Does not include
* decimal separator, exponent, sign, terminator. Currently does not affect
diff --git a/main/spprintf.c b/main/spprintf.c
index 079089c0fc..67ab15dce5 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -198,7 +198,8 @@ static size_t strnlen(const char *s, size_t maxlen) {
static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt, va_list ap) /* {{{ */
{
char *s = NULL;
- int s_len, free_zcopy;
+ size_t s_len;
+ int free_zcopy;
zval *zvp, zcopy;
int min_width = 0;
@@ -366,6 +367,16 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
modifier = LM_SIZE_T;
#endif
break;
+ case 'p': {
+ char __next = *(fmt+1);
+ if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) {
+ fmt++;
+ modifier = LM_PHP_INT_T;
+ } else {
+ modifier = LM_STD;
+ }
+ }
+ break;
case 'h':
fmt++;
if (*fmt == 'h') {
@@ -431,6 +442,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_ulong);
+ break;
}
/*
* The rest also applies to other integer formats, so fall
@@ -473,6 +487,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ i_num = (wide_int) va_arg(ap, zend_long);
+ break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -518,6 +535,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
@@ -558,6 +578,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
+ case LM_PHP_INT_T:
+ ui_num = (u_wide_int) va_arg(ap, zend_ulong);
+ break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
@@ -796,10 +819,10 @@ skip_output:
/*
* This is the general purpose conversion function.
*/
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
+PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
{
smart_string buf = {0};
- int result;
+ size_t result;
xbuf_format_converter(&buf, 1, format, ap);
@@ -821,9 +844,9 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap
}
/* }}} */
-PHPAPI int spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */
+PHPAPI size_t spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */
{
- int cc;
+ size_t cc;
va_list ap;
va_start(ap, format);
diff --git a/main/spprintf.h b/main/spprintf.h
index ae26a3b9ec..1e4782843f 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -37,9 +37,9 @@ There is also snprintf: See difference explained in snprintf.h
#include "snprintf.h"
BEGIN_EXTERN_C()
-PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
+PHPAPI size_t spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
-PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
+PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap);
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 78073c6187..cb4f081655 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -76,7 +76,7 @@ static int stream_cookie_writer(void *cookie, const char *buffer, int size)
return php_stream_write((php_stream *)cookie, (char *)buffer, size);
}
-static PHP_FPOS_T stream_cookie_seeker(void *cookie, off_t position, int whence)
+static PHP_FPOS_T stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
{
TSRMLS_FETCH();
@@ -114,7 +114,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
{
TSRMLS_FETCH();
- *position = php_stream_seek((php_stream *)cookie, (off_t)*position, whence);
+ *position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence);
if (*position == -1) {
return -1;
@@ -122,7 +122,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence)
return 0;
}
# else
-static int stream_cookie_seeker(void *cookie, off_t position, int whence)
+static int stream_cookie_seeker(void *cookie, zend_off_t position, int whence)
{
TSRMLS_FETCH();
@@ -206,7 +206,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
if (ret && castas != PHP_STREAM_AS_FD_FOR_SELECT) {
php_stream_flush(stream);
if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- off_t dummy;
+ zend_off_t dummy;
stream->ops->seek(stream, stream->position, SEEK_SET, &dummy TSRMLS_CC);
stream->readpos = stream->writepos = 0;
@@ -246,7 +246,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
}
if (*ret != NULL) {
- off_t pos;
+ zend_off_t pos;
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_FOPENCOOKIE;
@@ -254,7 +254,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
* the stdio layer to believe it's real location. */
pos = php_stream_tell(stream);
if (pos > 0) {
- fseek(*ret, pos, SEEK_SET);
+ zend_fseek(*ret, pos, SEEK_SET);
}
goto exit_success;
@@ -334,7 +334,7 @@ exit_success:
* will be accessing the stream. Emit a warning so that the end-user will
* know that they should try something else */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld bytes of buffered data lost during stream conversion!", (long)(stream->writepos - stream->readpos));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, ZEND_LONG_FMT " bytes of buffered data lost during stream conversion!", (zend_long)(stream->writepos - stream->readpos));
}
if (castas == PHP_STREAM_AS_STDIO && ret) {
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 5a48584f4e..f0c8a347f0 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -47,7 +47,7 @@ typedef struct {
size_t pattern_len;
} glob_s_t;
-PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, int *plen STREAMS_DC TSRMLS_DC) /* {{{ */
+PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *plen STREAMS_DC TSRMLS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
@@ -69,7 +69,7 @@ PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, int *plen S
}
/* }}} */
-PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, int *plen STREAMS_DC TSRMLS_DC) /* {{{ */
+PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, size_t *plen STREAMS_DC TSRMLS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
@@ -180,7 +180,7 @@ static int php_glob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
}
/* {{{ */
-static int php_glob_stream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) /* {{{ */
+static int php_glob_stream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 5da0c8decd..f08c192581 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -127,7 +127,7 @@ static int php_stream_memory_flush(php_stream *stream TSRMLS_DC)
/* {{{ */
-static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_stream_memory_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
assert(ms != NULL);
@@ -442,7 +442,7 @@ static int php_stream_temp_flush(php_stream *stream TSRMLS_DC)
/* {{{ */
-static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_stream_temp_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
int ret;
@@ -468,7 +468,7 @@ static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRML
php_stream *file;
size_t memsize;
char *membuf;
- off_t pos;
+ zend_off_t pos;
assert(ts != NULL);
@@ -584,7 +584,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char
{
php_stream *stream;
php_stream_temp_data *ts;
- off_t newoffs;
+ zend_off_t newoffs;
if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
if (length) {
@@ -618,7 +618,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
php_stream_temp_data *ts;
char *comma, *semi, *sep, *key;
size_t mlen, dlen, plen, vlen;
- off_t newoffs;
+ zend_off_t newoffs;
zval meta;
int base64 = 0, ilen;
zend_string *base64_comma = NULL;
@@ -741,7 +741,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
ZVAL_COPY_VALUE(&ts->meta, &meta);
}
if (base64_comma) {
- STR_FREE(base64_comma);
+ zend_string_free(base64_comma);
} else {
efree(comma);
}
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 050e95f285..a99c8994aa 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -51,7 +51,7 @@ PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC)
return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
}
-PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC)
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC)
{
int ret = 1;
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index d0322f7190..b6746b72ed 100644
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -23,10 +23,10 @@ PHPAPI extern php_stream_ops php_glob_stream_ops;
BEGIN_EXTERN_C()
-PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, int *plen STREAMS_DC TSRMLS_DC);
+PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *plen STREAMS_DC TSRMLS_DC);
#define php_glob_stream_get_path(stream, copy, plen) _php_glob_stream_get_path((stream), (copy), (plen) STREAMS_CC TSRMLS_CC)
-PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, int *plen STREAMS_DC TSRMLS_DC);
+PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, size_t *plen STREAMS_DC TSRMLS_DC);
#define php_glob_stream_get_pattern(stream, copy, plen) _php_glob_stream_get_pattern((stream), (copy), (plen) STREAMS_CC TSRMLS_CC)
PHPAPI int _php_glob_stream_get_count(php_stream *stream, int *pflags STREAMS_DC TSRMLS_DC);
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index b3570be48c..5d200d729a 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -74,7 +74,7 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC);
#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC)
-PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC);
+PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC);
#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)
END_EXTERN_C()
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index a6797ed898..50beb89551 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -142,21 +142,21 @@ typedef struct _php_stream_xport_param {
struct {
char *name;
size_t namelen;
- int backlog;
struct timeval *timeout;
struct sockaddr *addr;
- socklen_t addrlen;
char *buf;
size_t buflen;
- long flags;
+ zend_long flags;
+ socklen_t addrlen;
+ int backlog;
} inputs;
struct {
php_stream *client;
- int returncode;
struct sockaddr *addr;
socklen_t addrlen;
zend_string *textaddr;
zend_string *error_text;
+ int returncode;
int error_code;
} outputs;
} php_stream_xport_param;
@@ -191,18 +191,18 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRML
END_EXTERN_C()
typedef struct _php_stream_xport_crypto_param {
- enum {
- STREAM_XPORT_CRYPTO_OP_SETUP,
- STREAM_XPORT_CRYPTO_OP_ENABLE
- } op;
struct {
+ php_stream *session;
int activate;
php_stream_xport_crypt_method_t method;
- php_stream *session;
} inputs;
struct {
int returncode;
} outputs;
+ enum {
+ STREAM_XPORT_CRYPTO_OP_SETUP,
+ STREAM_XPORT_CRYPTO_OP_ENABLE
+ } op;
} php_stream_xport_crypto_param;
BEGIN_EXTERN_C()
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 87312b9ef8..de84c01a11 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -53,6 +53,12 @@ extern int php_get_uid_by_name(const char *name, uid_t *uid TSRMLS_DC);
extern int php_get_gid_by_name(const char *name, gid_t *gid TSRMLS_DC);
#endif
+#if defined(PHP_WIN32)
+# define PLAIN_WRAP_BUF_SIZE(st) (((st) > UINT_MAX) ? UINT_MAX : (unsigned int)(st))
+#else
+# define PLAIN_WRAP_BUF_SIZE(st) (st)
+#endif
+
/* parse standard "fopen" modes into open() flags */
PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags)
{
@@ -132,7 +138,7 @@ typedef struct {
HANDLE file_mapping;
#endif
- struct stat sb;
+ zend_stat_t sb;
} php_stdio_stream_data;
#define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd
@@ -143,7 +149,7 @@ static int do_fstat(php_stdio_stream_data *d, int force)
int r;
PHP_STDIOP_GET_FD(fd, d);
- r = fstat(fd, &d->sb);
+ r = zend_fstat(fd, &d->sb);
d->cached_fstat = r == 0;
return r;
@@ -246,9 +252,9 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = lseek(self->fd, 0, SEEK_CUR);
+ stream->position = zend_lseek(self->fd, 0, SEEK_CUR);
#ifdef ESPIPE
- if (stream->position == (off_t)-1 && errno == ESPIPE) {
+ if (stream->position == (zend_off_t)-1 && errno == ESPIPE) {
stream->position = 0;
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
self->is_pipe = 1;
@@ -285,7 +291,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = ftell(file);
+ stream->position = zend_ftell(file);
}
}
@@ -342,13 +348,13 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
assert(data != NULL);
if (data->fd >= 0) {
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
if (ret == (size_t)-1 && errno == EINTR) {
/* Read was interrupted, retry once,
If read still fails, giveup with feof==0
so script can retry if desired */
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
}
stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR && errno != EBADF));
@@ -356,7 +362,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
} else {
#if HAVE_FLUSHIO
if (!data->is_pipe && data->last_op == 'w')
- fseek(data->file, 0, SEEK_CUR);
+ zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
#endif
@@ -445,7 +451,7 @@ static int php_stdiop_flush(php_stream *stream TSRMLS_DC)
return 0;
}
-static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
+static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC)
{
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
int ret;
@@ -458,18 +464,18 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *
}
if (data->fd >= 0) {
- off_t result;
+ zend_off_t result;
- result = lseek(data->fd, offset, whence);
- if (result == (off_t)-1)
+ result = zend_lseek(data->fd, offset, whence);
+ if (result == (zend_off_t)-1)
return -1;
*newoffset = result;
return 0;
} else {
- ret = fseek(data->file, offset, whence);
- *newoffset = ftell(data->file);
+ ret = zend_fseek(data->file, offset, whence);
+ *newoffset = zend_ftell(data->file);
return ret;
}
}
@@ -831,7 +837,7 @@ static int php_plain_files_dirstream_close(php_stream *stream, int close_handle
return closedir((DIR *)stream->abstract);
}
-static int php_plain_files_dirstream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_plain_files_dirstream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
rewinddir((DIR *)stream->abstract);
return 0;
@@ -1096,7 +1102,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
#ifndef PHP_WIN32
# ifdef EXDEV
if (errno == EXDEV) {
- struct stat sb;
+ zend_stat_t sb;
if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
# if !defined(TSRM_WIN32) && !defined(NETWARE)
@@ -1159,7 +1165,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
} else {
/* we look for directory separator from the end of string, thus hopefuly reducing our work load */
char *e;
- struct stat sb;
+ zend_stat_t sb;
int dir_len = strlen(dir);
int offset = 0;
char buf[MAXPATHLEN];
@@ -1330,7 +1336,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
break;
#endif
case PHP_STREAM_META_ACCESS:
- mode = (mode_t)*(long *)value;
+ mode = (mode_t)*(zend_long *)value;
ret = VCWD_CHMOD(url, mode);
break;
default:
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 89537bdaeb..5cce2c66bf 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -572,7 +572,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
/* {{{ generic stream operations */
-static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC)
+PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC)
{
/* allocate/fill the buffer */
@@ -675,7 +675,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D
} else {
/* is there enough data in the buffer ? */
- if (stream->writepos - stream->readpos < (off_t)size) {
+ if (stream->writepos - stream->readpos < (zend_off_t)size) {
size_t justread = 0;
/* reduce buffer memory consumption if possible, to avoid a realloc */
@@ -740,7 +740,7 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS
break;
}
} else {
- php_stream_fill_read_buffer(stream, size TSRMLS_CC);
+ php_stream_fill_read_buffer(stream, size);
toread = stream->writepos - stream->readpos;
if (toread > size) {
@@ -976,7 +976,7 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen,
}
}
- php_stream_fill_read_buffer(stream, toread TSRMLS_CC);
+ php_stream_fill_read_buffer(stream, toread);
if (stream->writepos - stream->readpos == 0) {
break;
@@ -1051,7 +1051,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
to_read_now = MIN(maxlen - buffered_len, stream->chunk_size);
- php_stream_fill_read_buffer(stream, buffered_len + to_read_now TSRMLS_CC);
+ php_stream_fill_read_buffer(stream, buffered_len + to_read_now);
just_read = STREAM_BUFFERED_AMOUNT(stream) - buffered_len;
@@ -1101,7 +1101,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
}
}
- ret_buf = STR_ALLOC(tent_ret_len, 0);
+ ret_buf = zend_string_alloc(tent_ret_len, 0);
/* php_stream_read will not call ops->read here because the necessary
* data is guaranteedly buffered */
ret_buf->len = php_stream_read(stream, ret_buf->val, tent_ret_len);
@@ -1269,12 +1269,12 @@ PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt,
return count;
}
-PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
+PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
{
return stream->position;
}
-PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
+PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC)
{
if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
/* flush to commit data written to the fopencookie FILE* */
@@ -1445,7 +1445,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
}
if (maxlen > 0) {
- result = STR_ALLOC(maxlen, persistent);
+ result = zend_string_alloc(maxlen, persistent);
ptr = result->val;
while ((len < maxlen) && !php_stream_eof(src)) {
ret = php_stream_read(src, ptr, maxlen - len);
@@ -1459,7 +1459,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
*ptr = '\0';
result->len = len;
} else {
- STR_FREE(result);
+ zend_string_free(result);
result = NULL;
}
return result;
@@ -1477,13 +1477,13 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
max_len = step;
}
- result = STR_ALLOC(max_len, persistent);
+ result = zend_string_alloc(max_len, persistent);
ptr = result->val;
while ((ret = php_stream_read(src, ptr, max_len - len))) {
len += ret;
if (len + min_room >= max_len) {
- result = STR_REALLOC(result, max_len + step, persistent);
+ result = zend_string_realloc(result, max_len + step, persistent);
max_len += step;
ptr = result->val + len;
} else {
@@ -1491,10 +1491,10 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
}
}
if (len) {
- result = STR_REALLOC(result, len, persistent);
+ result = zend_string_realloc(result, len, persistent);
result->val[len] = '\0';
} else {
- STR_FREE(result);
+ zend_string_free(result);
result = NULL;
}
@@ -2136,7 +2136,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (stream && stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && strchr(mode, 'a') && stream->position == 0) {
- off_t newpos = 0;
+ zend_off_t newpos = 0;
/* if opened for append, we need to revise our idea of the initial file position */
if (0 == stream->ops->seek(stream, 0, SEEK_CUR, &newpos TSRMLS_CC)) {
@@ -2310,7 +2310,7 @@ PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], in
vector = (zend_string **) safe_erealloc(vector, vector_size, sizeof(char *), 0);
}
- vector[nfiles] = STR_INIT(sdp.d_name, strlen(sdp.d_name), 0);
+ vector[nfiles] = zend_string_init(sdp.d_name, strlen(sdp.d_name), 0);
nfiles++;
if(vector_size < 10 || nfiles == 0) {
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 7792e24fef..b1f0acfa73 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -46,7 +46,7 @@ PHPAPI int php_stream_xport_unregister(const char *protocol TSRMLS_DC)
#define ERR_RETURN(out_err, local_err, fmt) \
if (out_err) { *out_err = local_err; } \
else { php_error_docref(NULL TSRMLS_CC, E_WARNING, fmt, local_err ? local_err->val : "Unspecified error"); \
- if (local_err) { STR_RELEASE(local_err); local_err = NULL; } \
+ if (local_err) { zend_string_release(local_err); local_err = NULL; } \
}
PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, int options,
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index c41826155c..a286104e29 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -490,7 +490,7 @@ PHP_FUNCTION(stream_wrapper_register)
zend_string *protocol, *classname;
struct php_user_stream_wrapper * uwrap;
zend_resource *rsrc;
- long flags = 0;
+ zend_long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &protocol, &classname, &flags) == FAILURE) {
RETURN_FALSE;
@@ -531,7 +531,7 @@ PHP_FUNCTION(stream_wrapper_register)
PHP_FUNCTION(stream_wrapper_unregister)
{
char *protocol;
- int protocol_len;
+ size_t protocol_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &protocol, &protocol_len) == FAILURE) {
RETURN_FALSE;
@@ -617,9 +617,9 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
/* don't allow strange buffer overruns due to bogus return */
if (didwrite > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote %ld bytes more data than requested (%ld written, %ld max)",
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " written, " ZEND_LONG_FMT " max)",
us->wrapper->classname,
- (long)(didwrite - count), (long)didwrite, (long)count);
+ (zend_long)(didwrite - count), (zend_long)didwrite, (zend_long)count);
didwrite = count;
}
@@ -654,8 +654,8 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
convert_to_string(&retval);
didread = Z_STRLEN(retval);
if (didread > count) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read %ld bytes more data than requested (%ld read, %ld max) - excess data will be lost",
- us->wrapper->classname, (long)(didread - count), (long)didread, (long)count);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " read, " ZEND_LONG_FMT " max) - excess data will be lost",
+ us->wrapper->classname, (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
didread = count;
}
if (didread > 0)
@@ -751,7 +751,7 @@ static int php_userstreamop_flush(php_stream *stream TSRMLS_DC)
return call_result;
}
-static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
zval func_name;
zval retval;
@@ -987,7 +987,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
case PHP_STREAM_TRUNCATE_SET_SIZE: {
ptrdiff_t new_size = *(ptrdiff_t*) ptrparam;
if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) {
- ZVAL_LONG(&args[0], (long)new_size);
+ ZVAL_LONG(&args[0], (zend_long)new_size);
call_result = call_user_function_ex(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
@@ -1454,7 +1454,7 @@ static int php_userstreamop_closedir(php_stream *stream, int close_handle TSRMLS
return 0;
}
-static int php_userstreamop_rewinddir(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
+static int php_userstreamop_rewinddir(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC)
{
zval func_name;
zval retval;
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index dad78beb13..12111511d6 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -39,6 +39,13 @@
# define MSG_PEEK 0
#endif
+#ifdef PHP_WIN32
+/* send/recv family on windows expects int */
+# define XP_SOCK_BUF_SIZE(sz) (((sz) > INT_MAX) ? INT_MAX : (int)(sz))
+#else
+# define XP_SOCK_BUF_SIZE(sz) (sz)
+#endif
+
php_stream_ops php_stream_generic_socket_ops;
PHPAPI php_stream_ops php_stream_socket_ops;
php_stream_ops php_stream_udp_socket_ops;
@@ -67,7 +74,7 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count
ptimeout = &sock->timeout;
retry:
- didwrite = send(sock->socket, buf, count, (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
+ didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
if (didwrite <= 0) {
long err = php_socket_errno();
@@ -95,8 +102,8 @@ retry:
} while (err == EINTR);
}
estr = php_socket_strerror(err, NULL, 0);
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of %ld bytes failed with errno=%ld %s",
- (long)count, err, estr);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%ld %s",
+ (zend_long)count, err, estr);
efree(estr);
}
@@ -144,7 +151,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- int nr_bytes = 0;
+ ssize_t nr_bytes = 0;
if (!sock || sock->socket == -1) {
return 0;
@@ -156,7 +163,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS
return 0;
}
- nr_bytes = recv(sock->socket, buf, count, (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);
+ nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);
stream->eof = (nr_bytes == 0 || (nr_bytes == -1 && php_socket_errno() != EWOULDBLOCK));
@@ -230,7 +237,7 @@ static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC
#if ZEND_WIN32
return 0;
#else
- return fstat(sock->socket, &ssb->sb);
+ return zend_fstat(sock->socket, &ssb->sb);
#endif
}
@@ -240,7 +247,8 @@ static inline int sock_sendto(php_netstream_data_t *sock, const char *buf, size_
{
int ret;
if (addr) {
- ret = sendto(sock->socket, buf, buflen, flags, addr, addrlen);
+ ret = sendto(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, addr, XP_SOCK_BUF_SIZE(addrlen));
+
return (ret == SOCK_CONN_ERR) ? -1 : ret;
}
return ((ret = send(sock->socket, buf, buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret;
@@ -257,12 +265,12 @@ static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t bu
int want_addr = textaddr || addr;
if (want_addr) {
- ret = recvfrom(sock->socket, buf, buflen, flags, (struct sockaddr*)&sa, &sl);
+ ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl);
ret = (ret == SOCK_CONN_ERR) ? -1 : ret;
php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl,
textaddr, addr, addrlen TSRMLS_CC);
} else {
- ret = recv(sock->socket, buf, buflen, flags);
+ ret = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags);
ret = (ret == SOCK_CONN_ERR) ? -1 : ret;
}