summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2019-02-23 00:03:14 +0000
committerGitHub2019-02-23 00:03:14 +0000
commita48297dfc1144931e18073a87ed83ea337e3d37a (patch)
treedbd421aeed4541b8392bb9cf9b5ea575244e1b83
parent01dbd02341d4afa753830a1e642a59c8f7a0bbee (diff)
Add php8 to travis and fix php7.4
- Use clang-format on the code - Improve portability wrt. php8 - Fix php7.4 compatibility. See https://dustri.org/b/fixing-snuffleupagus-sloppy-comparison-on-array_keys-for-php74.html for a detailed writeup
-rw-r--r--.travis.yml6
-rw-r--r--src/sp_config_keywords.c5
-rw-r--r--src/sp_disabled_functions.c7
-rw-r--r--src/sp_session.c4
-rw-r--r--src/sp_sloppy.c21
-rw-r--r--src/sp_utils.c2
6 files changed, 24 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
index 8c0c309..326a3af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,8 @@ matrix:
28 php: "7.2" 28 php: "7.2"
29 - env: TARGET="gcc php7.3" CC="gcc" 29 - env: TARGET="gcc php7.3" CC="gcc"
30 php: "7.3" 30 php: "7.3"
31 - env: TARGET="gcc php7.3" CC="gcc"
32 php: "7.4snapshot"
31 - env: TARGET="gcc php nightly" CC="gcc" 33 - env: TARGET="gcc php nightly" CC="gcc"
32 php: "nightly" 34 php: "nightly"
33 allow_failures: 35 allow_failures:
@@ -55,5 +57,5 @@ after_success:
55 fi 57 fi
56 58
57after_failure: 59after_failure:
58 - grep -r . ./tests/*.out 60 - grep -r . ./tests/*/*.out
59 - grep -r . ./tests/*.diff 61 - grep -r . ./tests/*/*.diff
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index 760961a..a9c71d4 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -41,8 +41,9 @@ int parse_session(char *line) {
41 return ret; 41 return ret;
42 } 42 }
43 43
44#if ( !HAVE_PHP_SESSION || defined(COMPILE_DL_SESSION) ) 44#if (!HAVE_PHP_SESSION || defined(COMPILE_DL_SESSION))
45 sp_log_err("config", 45 sp_log_err(
46 "config",
46 "You're trying to use the session cookie encryption feature " 47 "You're trying to use the session cookie encryption feature "
47 "on line %zu without having session support statically built into PHP. " 48 "on line %zu without having session support statically built into PHP. "
48 "This isn't supported, see " 49 "This isn't supported, see "
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index bb22f71..0f42f8f 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -371,11 +371,8 @@ static void should_disable(zend_execute_data* execute_data,
371 } 371 }
372 372
373 if (config_node->r_value || config_node->value) { 373 if (config_node->r_value || config_node->value) {
374 if (check_is_builtin_name(config_node) && 374 if (check_is_builtin_name(config_node) && !config_node->var &&
375 !config_node->var && 375 !config_node->key && !config_node->r_key && !config_node->param &&
376 !config_node->key &&
377 !config_node->r_key &&
378 !config_node->param &&
379 !config_node->r_param) { 376 !config_node->r_param) {
380 if (false == is_param_matching(execute_data, config_node, builtin_param, 377 if (false == is_param_matching(execute_data, config_node, builtin_param,
381 &arg_name, builtin_param_name, 378 &arg_name, builtin_param_name,
diff --git a/src/sp_session.c b/src/sp_session.c
index c708ea0..0f45f9b 100644
--- a/src/sp_session.c
+++ b/src/sp_session.c
@@ -3,7 +3,7 @@
3 3
4ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) 4ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
5 5
6#if ( HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) ) 6#if (HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION))
7 7
8#ifdef ZTS 8#ifdef ZTS
9static ts_rsrc_id session_globals_id = 0; 9static ts_rsrc_id session_globals_id = 0;
@@ -165,6 +165,6 @@ void hook_session() {
165 165
166#else 166#else
167 167
168void hook_session() { } 168void hook_session() {}
169 169
170#endif // HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) 170#endif // HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c
index d510181..8c36822 100644
--- a/src/sp_sloppy.c
+++ b/src/sp_sloppy.c
@@ -43,20 +43,21 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name,
43 zval func_name; 43 zval func_name;
44 zval params[3]; 44 zval params[3];
45 zval *value, *array = NULL; 45 zval *value, *array = NULL;
46 zend_bool strict = 1; 46 zend_bool strict = 0;
47 uint32_t nb_params = ZEND_NUM_ARGS();
47 48
48 memset(&params, 0, sizeof(params)); 49 zend_parse_parameters(nb_params, spec, &value, &array, &strict);
49
50 zend_parse_parameters(ZEND_NUM_ARGS(), spec, &value, &array, &strict);
51 50
52 ZVAL_COPY(&params[0], value); 51 ZVAL_COPY(&params[0], value);
52 ZVAL_BOOL(&params[2], 1); // we want to always have strict mode enabled
53
53 if (array) { 54 if (array) {
54 ZVAL_COPY(&params[1], array); 55 ZVAL_COPY(&params[1], array);
55 ZVAL_BOOL(&params[2], 1); 56 // Lie about the number of parameters,
57 // since we are always passing strict = 1
58 nb_params = 3;
56 } else { 59 } else {
57 // if there is no array as parameter, don't set strict mode. 60 ZVAL_NULL(&params[1]);
58 // check php's implementation for details.
59 ZVAL_BOOL(&params[2], 0);
60 } 61 }
61 62
62 ZVAL_STRING(&func_name, name); 63 ZVAL_STRING(&func_name, name);
@@ -67,8 +68,8 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name,
67 zend_hash_str_find_ptr(CG(function_table), name, size); 68 zend_hash_str_find_ptr(CG(function_table), name, size);
68 func->handler = handler; 69 func->handler = handler;
69 70
70 call_user_function(CG(function_table), NULL, &func_name, return_value, 3, 71 call_user_function(CG(function_table), NULL, &func_name, return_value,
71 params); 72 nb_params, params);
72 73
73 func->handler = orig_handler; 74 func->handler = orig_handler;
74} 75}
diff --git a/src/sp_utils.c b/src/sp_utils.c
index acac310..1231bee 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -344,7 +344,9 @@ int hook_function(const char* original_name, HashTable* hook_table,
344 } 344 }
345 } 345 }
346 346
347#if PHP_VERSION_ID < 80000
347 CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN; 348 CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN;
349#endif
348 350
349 if (0 == strncmp(original_name, "mb_", 3) && !CG(multibyte)) { 351 if (0 == strncmp(original_name, "mb_", 3) && !CG(multibyte)) {
350 if (zend_hash_str_find(CG(function_table), 352 if (zend_hash_str_find(CG(function_table),