From b4dcbe2dd11efda09adc934fa2563eafc12e9b55 Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Thu, 2 Sep 2021 13:58:01 +0200 Subject: fixed compiler warnings + test cases --- src/sp_config_keywords.c | 2 +- src/sp_config_scanner.cached.c | 14 +++++++------- src/sp_config_scanner.re | 14 +++++++------- .../broken_conf_cookie_encryption_without_env_var.phpt | 2 +- .../cookies_encryption_warning/encrypt_cookies_no_env.phpt | 2 +- .../encrypt_regexp_cookies_no_env.phpt | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index fd90453..3b6bc0b 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c @@ -183,7 +183,7 @@ SP_PARSE_FN(parse_cookie) { if (cookie->encrypt) { if (!SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var) { sp_log_err("config", "You're trying to use the cookie encryption feature on line %zu " - "without having set the `." SP_TOKEN_ENV_VAR "` option in`sp.global`: please set it first", parsed_rule->lineno); + "without having set the `." SP_TOKEN_ENV_VAR "` option in `sp.global`: please set it first", parsed_rule->lineno); goto err; } else if (!SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key) { sp_log_err("config", "You're trying to use the cookie encryption feature " diff --git a/src/sp_config_scanner.cached.c b/src/sp_config_scanner.cached.c index 26a6652..868d271 100644 --- a/src/sp_config_scanner.cached.c +++ b/src/sp_config_scanner.cached.c @@ -154,7 +154,7 @@ const char *yyt4; zend_hash_str_add_ptr(&vars, ZEND_STRL("PHP_VERSION_ID"), zend_string_init(ZEND_STRL(ZEND_TOSTR(PHP_VERSION_ID)), 1)); - int cond_res[100] = {0}; + int cond_res[100] = {1}; int cond_res_i = 0; char cond_op[100] = {0}; int cond_op_i = 0; @@ -883,7 +883,7 @@ yy111: if (cond_op_i == 0 || sy_op_peek() != '(') { cs_error_log("unbalanced parathesis on line %d", lineno); goto out; } - sy_op_pop(); + cond_op_i--; goto yyc_cond_op; } yy113: @@ -910,12 +910,12 @@ yy116: case '>': op1 = 'G'; break; // >= } } - while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1)) && sy_op_is_left_assoc(*t1))) { - SY_APPLY_OP_FROM_STACK(); - } - sy_op_push(*t1); - goto yyc_cond; + while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1) && sy_op_is_left_assoc(*t1)))) { + SY_APPLY_OP_FROM_STACK(); } + sy_op_push(*t1); + goto yyc_cond; + } yy117: yych = *++YYCURSOR; if (yych == '=') goto yy119; diff --git a/src/sp_config_scanner.re b/src/sp_config_scanner.re index f911df3..5fd1928 100644 --- a/src/sp_config_scanner.re +++ b/src/sp_config_scanner.re @@ -143,7 +143,7 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key zend_hash_str_add_ptr(&vars, ZEND_STRL("PHP_VERSION_ID"), zend_string_init(ZEND_STRL(ZEND_TOSTR(PHP_VERSION_ID)), 1)); - int cond_res[100] = {0}; + int cond_res[100] = {1}; int cond_res_i = 0; char cond_op[100] = {0}; int cond_op_i = 0; @@ -220,12 +220,12 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key case '>': op1 = 'G'; break; // >= } } - while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1)) && sy_op_is_left_assoc(*t1))) { - SY_APPLY_OP_FROM_STACK(); - } - sy_op_push(*t1); - goto yyc_cond; + while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1) && sy_op_is_left_assoc(*t1)))) { + SY_APPLY_OP_FROM_STACK(); } + sy_op_push(*t1); + goto yyc_cond; + } ")" { while (cond_op_i && sy_op_peek() != '(') { SY_APPLY_OP_FROM_STACK(); @@ -233,7 +233,7 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key if (cond_op_i == 0 || sy_op_peek() != '(') { cs_error_log("unbalanced parathesis on line %d", lineno); goto out; } - sy_op_pop(); + cond_op_i--; goto yyc_cond_op; } ";" { diff --git a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt b/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt index 25371dd..99e391e 100644 --- a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt +++ b/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt @@ -7,7 +7,7 @@ Broken configuration - encrypted cookie with without cookie env var sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_env_var.ini --FILE-- --EXPECT-- -Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 +Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 Could not startup. diff --git a/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt b/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt index a01c352..b31bf78 100644 --- a/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt @@ -18,4 +18,4 @@ EOF; --EXPECT-- Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 -Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 +Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 diff --git a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt index 1fe4074..d4b7e6a 100644 --- a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt @@ -18,4 +18,4 @@ EOF; --EXPECT-- Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 -Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 +Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 -- cgit v1.3