summaryrefslogtreecommitdiff
path: root/src/sp_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_config.c')
-rw-r--r--src/sp_config.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/sp_config.c b/src/sp_config.c
index 7294b0e..ff6cdd9 100644
--- a/src/sp_config.c
+++ b/src/sp_config.c
@@ -4,9 +4,7 @@
4 4
5#include "php_snuffleupagus.h" 5#include "php_snuffleupagus.h"
6 6
7 7static const sp_config_keyword sp_func[] = {
8static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
9 sp_config_keyword sp_func[] = {
10 {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))}, 8 {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))},
11 {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)}, 9 {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)},
12 {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, 10 {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))},
@@ -25,11 +23,14 @@ static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
25 {parse_wrapper_whitelist, SP_TOKEN_ALLOW_WRAPPERS, &(SPCFG(wrapper))}, 23 {parse_wrapper_whitelist, SP_TOKEN_ALLOW_WRAPPERS, &(SPCFG(wrapper))},
26 {parse_ini_protection, SP_TOKEN_INI_PROTECTION, &(SPCFG(ini))}, 24 {parse_ini_protection, SP_TOKEN_INI_PROTECTION, &(SPCFG(ini))},
27 {parse_ini_entry, SP_TOKEN_INI, NULL}, 25 {parse_ini_entry, SP_TOKEN_INI, NULL},
28 {NULL, NULL, NULL}}; 26 {NULL, NULL, NULL}
27};
28
29static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
29 return sp_process_rule(parsed_rule, sp_func); 30 return sp_process_rule(parsed_rule, sp_func);
30} 31}
31 32
32zend_result sp_parse_config(const char *filename) { 33zend_result sp_parse_config(const char *const filename) {
33 FILE *fd = fopen(filename, "rb"); 34 FILE *fd = fopen(filename, "rb");
34 if (fd == NULL) { 35 if (fd == NULL) {
35 sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno)); 36 sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno));
@@ -65,10 +66,10 @@ zend_result sp_parse_config(const char *filename) {
65} 66}
66 67
67 68
68zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, sp_config_keyword *config_keywords) { 69zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *const config_keywords) {
69 for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) { 70 for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) {
70 bool found_kw = false; 71 bool found_kw = false;
71 for (sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) { 72 for (const sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) {
72 if (kw->kwlen == strlen(ckw->token) && !strncmp(kw->kw, ckw->token, kw->kwlen)) { 73 if (kw->kwlen == strlen(ckw->token) && !strncmp(kw->kw, ckw->token, kw->kwlen)) {
73 if (ckw->func) { 74 if (ckw->func) {
74 int ret = ckw->func(ckw->token, kw, ckw->retval); 75 int ret = ckw->func(ckw->token, kw, ckw->retval);
@@ -119,13 +120,12 @@ SP_PARSEKW_FN(parse_list) {
119 CHECK_DUPLICATE_KEYWORD(retval); 120 CHECK_DUPLICATE_KEYWORD(retval);
120 121
121 sp_list_node **list = retval; 122 sp_list_node **list = retval;
122 char *tok, *tmp;
123 123
124 SP_PARSE_ARG(value); 124 SP_PARSE_ARG(value);
125 125
126 tmp = ZSTR_VAL(value); 126 char* tmp = ZSTR_VAL(value);
127 while (1) { 127 while (1) {
128 tok = strsep(&tmp, ","); 128 const char* const tok = strsep(&tmp, ",");
129 if (tok == NULL) { 129 if (tok == NULL) {
130 break; 130 break;
131 } 131 }