summaryrefslogtreecommitdiff
path: root/src/sp_upload_validation.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-09-23 12:23:40 +0200
committerBen Fuhrmannek2021-09-23 12:23:40 +0200
commit54c352c1b5aa08b187dd1e52e544709cad2b0fee (patch)
treed15bf0f484c6baa1f2718e625e0d49f6fb488507 /src/sp_upload_validation.c
parent887e1c9d44fbcf5f23a928269034593b8521aaba (diff)
config is stack allocated now + some code improvements (see details)
* for easier memory manegement, the entire sp_config struct was merged into snuffleupagus_globals and allocated on stack where possible * SNUFFLEUPAGUS_G() can be written as SPG(), which is faster to type and easier to read * execution_depth is re-initialized to 0 for each request * function calls with inline string and length parameters consistently use ZEND_STRL instead of sizeof()-1 * execution is actually hooked if recursion protection is enabled * some line breaks were removed to make the code more readable
Diffstat (limited to 'src/sp_upload_validation.c')
-rw-r--r--src/sp_upload_validation.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/sp_upload_validation.c b/src/sp_upload_validation.c
index 4d44011..bff7e43 100644
--- a/src/sp_upload_validation.c
+++ b/src/sp_upload_validation.c
@@ -32,8 +32,7 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) {
32 32
33 if (event == MULTIPART_EVENT_END) { 33 if (event == MULTIPART_EVENT_END) {
34 zend_string *file_key __attribute__((unused)) = NULL; 34 zend_string *file_key __attribute__((unused)) = NULL;
35 const sp_config_upload_validation *config_upload = 35 const sp_config_upload_validation *config_upload = &(SPCFG(upload_validation));
36 SNUFFLEUPAGUS_G(config).config_upload_validation;
37 zval *file; 36 zval *file;
38 pid_t pid; 37 pid_t pid;
39 38
@@ -44,12 +43,9 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) {
44 ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]), 43 ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]),
45 file_key, file) { // for each uploaded file 44 file_key, file) { // for each uploaded file
46 45
47 char *filename = Z_STRVAL_P( 46 char *filename = Z_STRVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("name")));
48 zend_hash_str_find(Z_ARRVAL_P(file), "name", sizeof("name") - 1)); 47 char *tmp_name = Z_STRVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("tmp_name")));
49 char *tmp_name = Z_STRVAL_P(zend_hash_str_find( 48 size_t filesize = Z_LVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("size")));
50 Z_ARRVAL_P(file), "tmp_name", sizeof("tmp_name") - 1));
51 size_t filesize = Z_LVAL_P(
52 zend_hash_str_find(Z_ARRVAL_P(file), "size", sizeof("size") - 1));
53 char *cmd[3] = {0}; 49 char *cmd[3] = {0};
54 char *env[5] = {0}; 50 char *env[5] = {0};
55 51