com php-src: first shot to fix session: ext/session/mod_files .c ext/session/mod_user.c ext/session/mod_user_cl ass.c ext/session/php_session.h
ext/session/session .c ext/standard/sha1.c ext/standard/sha1.h
| From: | Anatol Belski | Date: | Fri, 22 Nov 2013 14:55:21 +0000 |
| Subject: | com php-src: first shot to fix session: ext/session/mod_files .c ext/session/mod_user.c ext/session/mod_user_cl ass.c ext/session/php_session.h ext/session/session .c ext/standard/sha1.c ext/standard/sha1.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74028@lists.php.net to get a copy of this message | ||
Commit: 639924fa2ccc5fd214725abef38afbd779e19ec0
Author: Anatol Belski <ab@php.net> Fri, 22 Nov 2013 15:55:21 +0100
Parents: db40b1c037da7a996274ae4c9e4835451be8abbc
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=639924fa2ccc5fd214725abef38afbd779e19ec0
Log:
first shot to fix session
Changed paths:
M ext/session/mod_files.c
M ext/session/mod_user.c
M ext/session/mod_user_class.c
M ext/session/php_session.h
M ext/session/session.c
M ext/standard/sha1.c
M ext/standard/sha1..h
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 004d9d4..c94d393 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -69,8 +69,8 @@ static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, cons { size_t key_len; const char *p; - int i; - int n; + size_t i; + size_t n; key_len = strlen(key); if (key_len <= data->dirdepth || @@ -169,12 +169,12 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC) } } -static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC) +static int ps_files_cleanup_dir(const char *dirname, php_int_t maxlifetime TSRMLS_DC) { DIR *dir; char dentry[sizeof(struct dirent) + MAXPATHLEN]; struct dirent *entry = (struct dirent *) &dentry; - struct stat sbuf; + php_stat_t sbuf; char buf[MAXPATHLEN]; time_t now; int nrdels = 0; @@ -225,7 +225,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC) static int ps_files_key_exists(ps_files *data, const char *key TSRMLS_DC) { char buf[MAXPATHLEN]; - struct stat sbuf; + php_stat_t sbuf; if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) { return FAILURE; diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 1b606b9..196a3ff 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -136,8 +136,8 @@ PS_READ_FUNC(user) if (retval) { if (Z_TYPE_P(retval) == IS_STRING) { - *val = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); - *vallen = Z_STRLEN_P(retval); + *val = estrndup(Z_STRVAL_P(retval), Z_STRSIZE_P(retval)); + *vallen = Z_STRSIZE_P(retval); ret = SUCCESS; } zval_ptr_dtor(&retval); @@ -194,7 +194,7 @@ PS_CREATE_SID_FUNC(user) if (retval) { if (Z_TYPE_P(retval) == IS_STRING) { - id = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + id = estrndup(Z_STRVAL_P(retval), Z_STRSIZE_P(retval)); } zval_ptr_dtor(&retval); } diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c index ea53af9..58ba63e 100644 --- a/ext/session/mod_user_class.c +++ b/ext/session/mod_user_class.c @@ -39,11 +39,11 @@ PHP_METHOD(SessionHandler, open) { char *save_path = NULL, *session_name = NULL; - int save_path_len, session_name_len; + zend_str_size_int save_path_len, session_name_len; PS_SANITY_CHECK; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) { return; } @@ -72,11 +72,11 @@ PHP_METHOD(SessionHandler, close) PHP_METHOD(SessionHandler, read) { char *key, *val; - int key_len, val_len; + zend_str_size_int key_len, val_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &key, &key_len) == FAILURE) { return; } @@ -96,11 +96,11 @@ PHP_METHOD(SessionHandler, read) PHP_METHOD(SessionHandler, write) { char *key, *val; - int key_len, val_len; + zend_str_size_int key_len, val_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &key, &key_len, &val, &val_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &key, &key_len, &val, &val_len) == FAILURE) { return; } @@ -113,11 +113,11 @@ PHP_METHOD(SessionHandler, write) PHP_METHOD(SessionHandler, destroy) { char *key; - int key_len; + zend_str_size_int key_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &key, &key_len) == FAILURE) { return; } @@ -129,12 +129,12 @@ PHP_METHOD(SessionHandler, destroy) Wraps the old gc handler */ PHP_METHOD(SessionHandler, gc) { - long maxlifetime; - int nrdels; + php_int_t maxlifetime; + php_int_t nrdels; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &maxlifetime) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &maxlifetime) == FAILURE) { return; } diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 4307e6a..8ca34e3 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -34,11 +34,11 @@ #define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name TSRMLS_DC #define PS_CLOSE_ARGS void **mod_data TSRMLS_DC -#define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC -#define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const int vallen TSRMLS_DC +#define PS_READ_ARGS void **mod_data, const char *key, char **val, zend_str_size_int *vallen TSRMLS_DC +#define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const zend_str_size_int vallen TSRMLS_DC #define PS_DESTROY_ARGS void **mod_data, const char *key TSRMLS_DC -#define PS_GC_ARGS void **mod_data, int maxlifetime, int *nrdels TSRMLS_DC -#define PS_CREATE_SID_ARGS void **mod_data, int *newlen TSRMLS_DC +#define PS_GC_ARGS void **mod_data, php_int_t maxlifetime, php_int_t *nrdels TSRMLS_DC +#define PS_CREATE_SID_ARGS void **mod_data, zend_str_size_int *newlen TSRMLS_DC /* default create id function */ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS); @@ -104,8 +104,8 @@ typedef struct _php_session_rfc1867_progress { zval sid; smart_str key; - long update_step; - long next_update; + php_int_t update_step; + php_int_t next_update; double next_update_time; zend_bool cancel_upload; zend_bool apply_trans_sid; @@ -137,7 +137,7 @@ typedef struct _php_ps_globals { php_session_status session_status; long gc_probability; long gc_divisor; - long gc_maxlifetime; + php_int_t gc_maxlifetime; int module_number; long cache_expire; union { @@ -194,8 +194,8 @@ extern zend_module_entry session_module_entry; #define PS(v) (ps_globals.v) #endif -#define PS_SERIALIZER_ENCODE_ARGS char **newstr, int *newlen TSRMLS_DC -#define PS_SERIALIZER_DECODE_ARGS const char *val, int vallen TSRMLS_DC +#define PS_SERIALIZER_ENCODE_ARGS char **newstr, zend_str_size_int *newlen TSRMLS_DC +#define PS_SERIALIZER_DECODE_ARGS const char *val, zend_str_size_int vallen TSRMLS_DC typedef struct ps_serializer_struct { const char *name; @@ -254,8 +254,8 @@ PHPAPI void php_session_reset_id(TSRMLS_D); #define PS_ENCODE_VARS \ char *key; \ - uint key_length; \ - ulong num_key; \ + zend_str_size_uint key_length; \ + php_uint_t num_key; \ zval **struc; #define PS_ENCODE_LOOP(code) do { \ @@ -266,7 +266,7 @@ PHPAPI void php_session_reset_id(TSRMLS_D); (key_type = zend_hash_get_current_key_ex(_ht, &key, &key_length, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; \ zend_hash_move_forward(_ht)) { \ if (key_type == HASH_KEY_IS_LONG) { \ - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numeric key %ld", num_key); \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numeric key " ZEND_INT_FMT, num_key); \ continue; \ } \ key_length--; \ diff --git a/ext/session/session.c b/ext/session/session.c index 5b4820a..fa4a384 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -197,7 +197,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */ } /* }}} */ -static char *php_session_encode(int *newlen TSRMLS_DC) /* {{{ */ +static char *php_session_encode(zend_str_size_int *newlen TSRMLS_DC) /* {{{ */ { char *ret = NULL; @@ -215,7 +215,7 @@ static char *php_session_encode(int *newlen TSRMLS_DC) /* {{{ */ } /* }}} */ -static void php_session_decode(const char *val, int vallen TSRMLS_DC) /* {{{ */ +static void php_session_decode(const char *val, zend_str_size_int vallen TSRMLS_DC) /* {{{ */ { if (!PS(serializer)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object"); @@ -467,7 +467,7 @@ PHPAPI int php_session_valid_key(const char *key) /* {{{ */ static void php_session_initialize(TSRMLS_D) /* {{{ */ { char *val = NULL; - int vallen; + zend_str_size_int vallen; if (!PS(mod)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "No storage module chosen - failed to initialize session"); @@ -534,7 +534,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ IF_SESSION_VARS() { if (PS(mod_data) || PS(mod_user_implemented)) { char *val; - int vallen; + zend_str_size_int vallen; val = php_session_encode(&vallen TSRMLS_CC); if (val) { @@ -1016,7 +1016,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */ char *name; const char *endptr = val + vallen; zval *current; - int namelen; + zend_str_size_int namelen; int has_value; php_unserialize_data_t var_hash; @@ -1174,7 +1174,7 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */ static inline void last_modified(TSRMLS_D) /* {{{ */ { const char *path; - struct stat sb; + php_stat_t sb; char buf[MAX_STR + 1]; path = SG(request_info).path_translated; @@ -1397,7 +1397,7 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{ #define PPID2SID \ convert_to_string((*ppid)); \ - PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid)) + PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRSIZE_PP(ppid)) PHPAPI void php_session_reset_id(TSRMLS_D) /* {{{ */ { @@ -1441,7 +1441,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ zval **data; char *p, *value; int nrand; - int lensess; + zend_str_size_int lensess; if (PS(use_only_cookies)) { PS(apply_trans_sid) = 0; @@ -1543,7 +1543,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ PG(http_globals)[TRACK_VARS_SERVER] && zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_REFERER", sizeof("HTTP_REFERER"), (void **) &data) == SUCCESS && Z_TYPE_PP(data) == IS_STRING && - Z_STRLEN_PP(data) != 0 && + Z_STRSIZE_PP(data) != 0 && strstr(Z_STRVAL_PP(data), PS(extern_referer_chk)) == NULL ) { efree(PS(id)); @@ -1565,7 +1565,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ php_session_cache_limiter(TSRMLS_C); if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) { - int nrdels = -1; + php_int_t nrdels = -1; nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg(TSRMLS_C)); if (nrand < PS(gc_probability)) { @@ -1627,17 +1627,18 @@ static PHP_FUNCTION(session_set_cookie_params) { zval **lifetime = NULL; char *path = NULL, *domain = NULL; - int path_len, domain_len, argc = ZEND_NUM_ARGS(); + zend_str_size_int path_len, domain_len; + int argc = ZEND_NUM_ARGS(); zend_bool secure = 0, httponly = 0; if (!PS(use_cookies) || - zend_parse_parameters(argc TSRMLS_CC, "Z|ssbb", &lifetime, &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE) { + zend_parse_parameters(argc TSRMLS_CC, "Z|SSbb", &lifetime, &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE) { return; } convert_to_string_ex(lifetime); - zend_alter_ini_entry("session.cookie_lifetime", sizeof("session.cookie_lifetime"), Z_STRVAL_PP(lifetime), Z_STRLEN_PP(lifetime), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + zend_alter_ini_entry("session.cookie_lifetime", sizeof("session.cookie_lifetime"), Z_STRVAL_PP(lifetime), Z_STRSIZE_PP(lifetime), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); if (path) { zend_alter_ini_entry("session.cookie_path", sizeof("session.cookie_path"), path, path_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); @@ -1678,9 +1679,9 @@ static PHP_FUNCTION(session_get_cookie_params) static PHP_FUNCTION(session_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1697,9 +1698,9 @@ static PHP_FUNCTION(session_name) static PHP_FUNCTION(session_module_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1732,9 +1733,9 @@ static PHP_FUNCTION(session_module_name) static PHP_FUNCTION(session_serializer_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1766,11 +1767,11 @@ static PHP_FUNCTION(session_set_save_handler) if (argc > 0 && argc <= 2) { zval *obj = NULL, *callback = NULL; - zend_uint func_name_len; + zend_str_size_uint func_name_len; char *func_name; HashPosition pos; zend_function *default_mptr, *current_mptr; - ulong func_index; + php_uint_t func_index; php_shutdown_function_entry shutdown_function_entry; zend_bool register_shutdown = 1; @@ -1898,9 +1899,9 @@ static PHP_FUNCTION(session_set_save_handler) static PHP_FUNCTION(session_save_path) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1922,9 +1923,10 @@ static PHP_FUNCTION(session_save_path) static PHP_FUNCTION(session_id) { char *name = NULL; - int name_len, argc = ZEND_NUM_ARGS(); + zend_str_size_int name_len; + int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1986,9 +1988,9 @@ static PHP_FUNCTION(session_regenerate_id) static PHP_FUNCTION(session_cache_limiter) { char *limiter = NULL; - int limiter_len; + zend_str_size_int limiter_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &limiter, &limiter_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &limiter, &limiter_len) == FAILURE) { return; } @@ -2015,7 +2017,7 @@ static PHP_FUNCTION(session_cache_expire) if (argc == 1) { convert_to_string_ex(expires); - zend_alter_ini_entry("session.cache_expire", sizeof("session.cache_expire"), Z_STRVAL_PP(expires), Z_STRLEN_PP(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zend_alter_ini_entry("session.cache_expire", sizeof("session.cache_expire"), Z_STRVAL_PP(expires), Z_STRSIZE_PP(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); } } /* }}} */ @@ -2024,7 +2026,7 @@ static PHP_FUNCTION(session_cache_expire) Serializes the current setup and returns the serialized representation */ static PHP_FUNCTION(session_encode) { - int len; + zend_str_size_int len; char *enc; if (zend_parse_parameters_none() == FAILURE) { @@ -2045,13 +2047,13 @@ static PHP_FUNCTION(session_encode) static PHP_FUNCTION(session_decode) { char *str; - int str_len; + zend_str_size_int str_len; if (PS(session_status) == php_session_none) { RETURN_FALSE; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, &str_len) == FAILURE) { return; } @@ -2147,10 +2149,10 @@ static PHP_FUNCTION(session_status) Execute garbage collection returns number of deleted data */ static PHP_FUNCTION(session_gc) { - int nrdels = -1; - long maxlifetime = PS(gc_maxlifetime); + php_int_t nrdels = -1; + php_int_t maxlifetime = PS(gc_maxlifetime); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &maxlifetime) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &maxlifetime) == FAILURE) { return; } @@ -2172,7 +2174,7 @@ static PHP_FUNCTION(session_gc) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session gc failed. Check permission or session storage"); RETURN_FALSE; } - RETURN_LONG((long)nrdels); + RETURN_LONG(nrdels); } /* }}} */ @@ -2761,7 +2763,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo add_assoc_zval_ex(progress->data, "files", sizeof("files"), progress->files); php_rinit_session(0 TSRMLS_CC); - PS(id) = estrndup(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid)); + PS(id) = estrndup(Z_STRVAL(progress->sid), Z_STRSIZE(progress->sid)); PS(apply_trans_sid) = progress->apply_trans_sid; PS(send_cookie) = 0; } diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c index e8b62d5..89b0805 100644 --- a/ext/standard/sha1.c +++ b/ext/standard/sha1.c @@ -181,7 +181,7 @@ PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX * context) context. */ PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *input, - unsigned int inputLen) + zend_str_size_uint inputLen) { unsigned int i, index, partLen; diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h index 450d457..ea8a09c 100644 --- a/ext/standard/sha1.h +++ b/ext/standard/sha1.h @@ -31,7 +31,7 @@ typedef struct { } PHP_SHA1_CTX; PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *); -PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int); +PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, zend_str_size_uint); PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *); PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest);
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 004d9d4..c94d393 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -69,8 +69,8 @@ static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, cons { size_t key_len; const char *p; - int i; - int n; + size_t i; + size_t n; key_len = strlen(key); if (key_len <= data->dirdepth || @@ -169,12 +169,12 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC) } } -static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC) +static int ps_files_cleanup_dir(const char *dirname, php_int_t maxlifetime TSRMLS_DC) { DIR *dir; char dentry[sizeof(struct dirent) + MAXPATHLEN]; struct dirent *entry = (struct dirent *) &dentry; - struct stat sbuf; + php_stat_t sbuf; char buf[MAXPATHLEN]; time_t now; int nrdels = 0; @@ -225,7 +225,7 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC) static int ps_files_key_exists(ps_files *data, const char *key TSRMLS_DC) { char buf[MAXPATHLEN]; - struct stat sbuf; + php_stat_t sbuf; if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) { return FAILURE; diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 1b606b9..196a3ff 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -136,8 +136,8 @@ PS_READ_FUNC(user) if (retval) { if (Z_TYPE_P(retval) == IS_STRING) { - *val = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); - *vallen = Z_STRLEN_P(retval); + *val = estrndup(Z_STRVAL_P(retval), Z_STRSIZE_P(retval)); + *vallen = Z_STRSIZE_P(retval); ret = SUCCESS; } zval_ptr_dtor(&retval); @@ -194,7 +194,7 @@ PS_CREATE_SID_FUNC(user) if (retval) { if (Z_TYPE_P(retval) == IS_STRING) { - id = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + id = estrndup(Z_STRVAL_P(retval), Z_STRSIZE_P(retval)); } zval_ptr_dtor(&retval); } diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c index ea53af9..58ba63e 100644 --- a/ext/session/mod_user_class.c +++ b/ext/session/mod_user_class.c @@ -39,11 +39,11 @@ PHP_METHOD(SessionHandler, open) { char *save_path = NULL, *session_name = NULL; - int save_path_len, session_name_len; + zend_str_size_int save_path_len, session_name_len; PS_SANITY_CHECK; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) { return; } @@ -72,11 +72,11 @@ PHP_METHOD(SessionHandler, close) PHP_METHOD(SessionHandler, read) { char *key, *val; - int key_len, val_len; + zend_str_size_int key_len, val_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &key, &key_len) == FAILURE) { return; } @@ -96,11 +96,11 @@ PHP_METHOD(SessionHandler, read) PHP_METHOD(SessionHandler, write) { char *key, *val; - int key_len, val_len; + zend_str_size_int key_len, val_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &key, &key_len, &val, &val_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &key, &key_len, &val, &val_len) == FAILURE) { return; } @@ -113,11 +113,11 @@ PHP_METHOD(SessionHandler, write) PHP_METHOD(SessionHandler, destroy) { char *key; - int key_len; + zend_str_size_int key_len; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &key, &key_len) == FAILURE) { return; } @@ -129,12 +129,12 @@ PHP_METHOD(SessionHandler, destroy) Wraps the old gc handler */ PHP_METHOD(SessionHandler, gc) { - long maxlifetime; - int nrdels; + php_int_t maxlifetime; + php_int_t nrdels; PS_SANITY_CHECK_IS_OPEN; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &maxlifetime) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &maxlifetime) == FAILURE) { return; } diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 4307e6a..8ca34e3 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -34,11 +34,11 @@ #define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name TSRMLS_DC #define PS_CLOSE_ARGS void **mod_data TSRMLS_DC -#define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC -#define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const int vallen TSRMLS_DC +#define PS_READ_ARGS void **mod_data, const char *key, char **val, zend_str_size_int *vallen TSRMLS_DC +#define PS_WRITE_ARGS void **mod_data, const char *key, const char *val, const zend_str_size_int vallen TSRMLS_DC #define PS_DESTROY_ARGS void **mod_data, const char *key TSRMLS_DC -#define PS_GC_ARGS void **mod_data, int maxlifetime, int *nrdels TSRMLS_DC -#define PS_CREATE_SID_ARGS void **mod_data, int *newlen TSRMLS_DC +#define PS_GC_ARGS void **mod_data, php_int_t maxlifetime, php_int_t *nrdels TSRMLS_DC +#define PS_CREATE_SID_ARGS void **mod_data, zend_str_size_int *newlen TSRMLS_DC /* default create id function */ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS); @@ -104,8 +104,8 @@ typedef struct _php_session_rfc1867_progress { zval sid; smart_str key; - long update_step; - long next_update; + php_int_t update_step; + php_int_t next_update; double next_update_time; zend_bool cancel_upload; zend_bool apply_trans_sid; @@ -137,7 +137,7 @@ typedef struct _php_ps_globals { php_session_status session_status; long gc_probability; long gc_divisor; - long gc_maxlifetime; + php_int_t gc_maxlifetime; int module_number; long cache_expire; union { @@ -194,8 +194,8 @@ extern zend_module_entry session_module_entry; #define PS(v) (ps_globals.v) #endif -#define PS_SERIALIZER_ENCODE_ARGS char **newstr, int *newlen TSRMLS_DC -#define PS_SERIALIZER_DECODE_ARGS const char *val, int vallen TSRMLS_DC +#define PS_SERIALIZER_ENCODE_ARGS char **newstr, zend_str_size_int *newlen TSRMLS_DC +#define PS_SERIALIZER_DECODE_ARGS const char *val, zend_str_size_int vallen TSRMLS_DC typedef struct ps_serializer_struct { const char *name; @@ -254,8 +254,8 @@ PHPAPI void php_session_reset_id(TSRMLS_D); #define PS_ENCODE_VARS \ char *key; \ - uint key_length; \ - ulong num_key; \ + zend_str_size_uint key_length; \ + php_uint_t num_key; \ zval **struc; #define PS_ENCODE_LOOP(code) do { \ @@ -266,7 +266,7 @@ PHPAPI void php_session_reset_id(TSRMLS_D); (key_type = zend_hash_get_current_key_ex(_ht, &key, &key_length, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; \ zend_hash_move_forward(_ht)) { \ if (key_type == HASH_KEY_IS_LONG) { \ - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numeric key %ld", num_key); \ + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numeric key " ZEND_INT_FMT, num_key); \ continue; \ } \ key_length--; \ diff --git a/ext/session/session.c b/ext/session/session.c index 5b4820a..fa4a384 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -197,7 +197,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */ } /* }}} */ -static char *php_session_encode(int *newlen TSRMLS_DC) /* {{{ */ +static char *php_session_encode(zend_str_size_int *newlen TSRMLS_DC) /* {{{ */ { char *ret = NULL; @@ -215,7 +215,7 @@ static char *php_session_encode(int *newlen TSRMLS_DC) /* {{{ */ } /* }}} */ -static void php_session_decode(const char *val, int vallen TSRMLS_DC) /* {{{ */ +static void php_session_decode(const char *val, zend_str_size_int vallen TSRMLS_DC) /* {{{ */ { if (!PS(serializer)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object"); @@ -467,7 +467,7 @@ PHPAPI int php_session_valid_key(const char *key) /* {{{ */ static void php_session_initialize(TSRMLS_D) /* {{{ */ { char *val = NULL; - int vallen; + zend_str_size_int vallen; if (!PS(mod)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "No storage module chosen - failed to initialize session"); @@ -534,7 +534,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ IF_SESSION_VARS() { if (PS(mod_data) || PS(mod_user_implemented)) { char *val; - int vallen; + zend_str_size_int vallen; val = php_session_encode(&vallen TSRMLS_CC); if (val) { @@ -1016,7 +1016,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */ char *name; const char *endptr = val + vallen; zval *current; - int namelen; + zend_str_size_int namelen; int has_value; php_unserialize_data_t var_hash; @@ -1174,7 +1174,7 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */ static inline void last_modified(TSRMLS_D) /* {{{ */ { const char *path; - struct stat sb; + php_stat_t sb; char buf[MAX_STR + 1]; path = SG(request_info).path_translated; @@ -1397,7 +1397,7 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{ #define PPID2SID \ convert_to_string((*ppid)); \ - PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid)) + PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRSIZE_PP(ppid)) PHPAPI void php_session_reset_id(TSRMLS_D) /* {{{ */ { @@ -1441,7 +1441,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ zval **data; char *p, *value; int nrand; - int lensess; + zend_str_size_int lensess; if (PS(use_only_cookies)) { PS(apply_trans_sid) = 0; @@ -1543,7 +1543,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ PG(http_globals)[TRACK_VARS_SERVER] && zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_REFERER", sizeof("HTTP_REFERER"), (void **) &data) == SUCCESS && Z_TYPE_PP(data) == IS_STRING && - Z_STRLEN_PP(data) != 0 && + Z_STRSIZE_PP(data) != 0 && strstr(Z_STRVAL_PP(data), PS(extern_referer_chk)) == NULL ) { efree(PS(id)); @@ -1565,7 +1565,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ php_session_cache_limiter(TSRMLS_C); if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) { - int nrdels = -1; + php_int_t nrdels = -1; nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg(TSRMLS_C)); if (nrand < PS(gc_probability)) { @@ -1627,17 +1627,18 @@ static PHP_FUNCTION(session_set_cookie_params) { zval **lifetime = NULL; char *path = NULL, *domain = NULL; - int path_len, domain_len, argc = ZEND_NUM_ARGS(); + zend_str_size_int path_len, domain_len; + int argc = ZEND_NUM_ARGS(); zend_bool secure = 0, httponly = 0; if (!PS(use_cookies) || - zend_parse_parameters(argc TSRMLS_CC, "Z|ssbb", &lifetime, &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE) { + zend_parse_parameters(argc TSRMLS_CC, "Z|SSbb", &lifetime, &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE) { return; } convert_to_string_ex(lifetime); - zend_alter_ini_entry("session.cookie_lifetime", sizeof("session.cookie_lifetime"), Z_STRVAL_PP(lifetime), Z_STRLEN_PP(lifetime), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + zend_alter_ini_entry("session.cookie_lifetime", sizeof("session.cookie_lifetime"), Z_STRVAL_PP(lifetime), Z_STRSIZE_PP(lifetime), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); if (path) { zend_alter_ini_entry("session.cookie_path", sizeof("session.cookie_path"), path, path_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); @@ -1678,9 +1679,9 @@ static PHP_FUNCTION(session_get_cookie_params) static PHP_FUNCTION(session_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1697,9 +1698,9 @@ static PHP_FUNCTION(session_name) static PHP_FUNCTION(session_module_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1732,9 +1733,9 @@ static PHP_FUNCTION(session_module_name) static PHP_FUNCTION(session_serializer_name) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1766,11 +1767,11 @@ static PHP_FUNCTION(session_set_save_handler) if (argc > 0 && argc <= 2) { zval *obj = NULL, *callback = NULL; - zend_uint func_name_len; + zend_str_size_uint func_name_len; char *func_name; HashPosition pos; zend_function *default_mptr, *current_mptr; - ulong func_index; + php_uint_t func_index; php_shutdown_function_entry shutdown_function_entry; zend_bool register_shutdown = 1; @@ -1898,9 +1899,9 @@ static PHP_FUNCTION(session_set_save_handler) static PHP_FUNCTION(session_save_path) { char *name = NULL; - int name_len; + zend_str_size_int name_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1922,9 +1923,10 @@ static PHP_FUNCTION(session_save_path) static PHP_FUNCTION(session_id) { char *name = NULL; - int name_len, argc = ZEND_NUM_ARGS(); + zend_str_size_int name_len; + int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "|S", &name, &name_len) == FAILURE) { return; } @@ -1986,9 +1988,9 @@ static PHP_FUNCTION(session_regenerate_id) static PHP_FUNCTION(session_cache_limiter) { char *limiter = NULL; - int limiter_len; + zend_str_size_int limiter_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &limiter, &limiter_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &limiter, &limiter_len) == FAILURE) { return; } @@ -2015,7 +2017,7 @@ static PHP_FUNCTION(session_cache_expire) if (argc == 1) { convert_to_string_ex(expires); - zend_alter_ini_entry("session.cache_expire", sizeof("session.cache_expire"), Z_STRVAL_PP(expires), Z_STRLEN_PP(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); + zend_alter_ini_entry("session.cache_expire", sizeof("session.cache_expire"), Z_STRVAL_PP(expires), Z_STRSIZE_PP(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); } } /* }}} */ @@ -2024,7 +2026,7 @@ static PHP_FUNCTION(session_cache_expire) Serializes the current setup and returns the serialized representation */ static PHP_FUNCTION(session_encode) { - int len; + zend_str_size_int len; char *enc; if (zend_parse_parameters_none() == FAILURE) { @@ -2045,13 +2047,13 @@ static PHP_FUNCTION(session_encode) static PHP_FUNCTION(session_decode) { char *str; - int str_len; + zend_str_size_int str_len; if (PS(session_status) == php_session_none) { RETURN_FALSE; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, &str_len) == FAILURE) { return; } @@ -2147,10 +2149,10 @@ static PHP_FUNCTION(session_status) Execute garbage collection returns number of deleted data */ static PHP_FUNCTION(session_gc) { - int nrdels = -1; - long maxlifetime = PS(gc_maxlifetime); + php_int_t nrdels = -1; + php_int_t maxlifetime = PS(gc_maxlifetime); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &maxlifetime) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &maxlifetime) == FAILURE) { return; } @@ -2172,7 +2174,7 @@ static PHP_FUNCTION(session_gc) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session gc failed. Check permission or session storage"); RETURN_FALSE; } - RETURN_LONG((long)nrdels); + RETURN_LONG(nrdels); } /* }}} */ @@ -2761,7 +2763,7 @@ static int php_session_rfc1867_callback(unsigned int event, void *event_data, vo add_assoc_zval_ex(progress->data, "files", sizeof("files"), progress->files); php_rinit_session(0 TSRMLS_CC); - PS(id) = estrndup(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid)); + PS(id) = estrndup(Z_STRVAL(progress->sid), Z_STRSIZE(progress->sid)); PS(apply_trans_sid) = progress->apply_trans_sid; PS(send_cookie) = 0; } diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c index e8b62d5..89b0805 100644 --- a/ext/standard/sha1.c +++ b/ext/standard/sha1.c @@ -181,7 +181,7 @@ PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX * context) context. */ PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *input, - unsigned int inputLen) + zend_str_size_uint inputLen) { unsigned int i, index, partLen; diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h index 450d457..ea8a09c 100644 --- a/ext/standard/sha1.h +++ b/ext/standard/sha1.h @@ -31,7 +31,7 @@ typedef struct { } PHP_SHA1_CTX; PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *); -PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int); +PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, zend_str_size_uint); PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *); PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest);