From 200e697807b4de3af042edb3dea4d3db8fba9f03 Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Fri, 23 Sep 2016 17:35:03 +0200 Subject: whitespace / code indentation --- ufilter.c | 266 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 133 insertions(+), 133 deletions(-) (limited to 'ufilter.c') diff --git a/ufilter.c b/ufilter.c index 203d76c..73573ad 100644 --- a/ufilter.c +++ b/ufilter.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ /* - $Id: ufilter.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ + $Id: ufilter.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ */ #ifdef HAVE_CONFIG_H @@ -48,12 +48,12 @@ static int check_fileupload_varname(char *varname TSRMLS_DC) /* Normalize the variable name */ normalize_varname(var); - + /* Find length of variable name */ index = strchr(var, '['); total_len = strlen(var); var_len = index ? index-var : total_len; - + /* Drop this variable if it exceeds the varname/total length limit */ if (SUHOSIN_G(max_varname_length) && SUHOSIN_G(max_varname_length) < var_len) { suhosin_log(S_FILES, "configured request variable name length limit exceeded - dropped variable '%s'", var); @@ -79,38 +79,38 @@ static int check_fileupload_varname(char *varname TSRMLS_DC) goto return_failure; } } - + /* Find out array depth */ while (index) { char *index_end; unsigned int index_length; - + /* overjump '[' */ index++; - + /* increase array depth */ depth++; - + index_end = strchr(index, ']'); if (index_end == NULL) { index_end = index+strlen(index); } - + index_length = index_end - index; - + if (SUHOSIN_G(max_array_index_length) && SUHOSIN_G(max_array_index_length) < index_length) { suhosin_log(S_FILES, "configured request variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN_G(simulation)) { goto return_failure; } - } + } if (SUHOSIN_G(max_post_array_index_length) && SUHOSIN_G(max_post_array_index_length) < index_length) { suhosin_log(S_FILES, "configured POST variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN_G(simulation)) { goto return_failure; } - } - + } + /* index whitelist/blacklist */ if (SUHOSIN_G(array_index_whitelist) && *(SUHOSIN_G(array_index_whitelist))) { if (suhosin_strnspn(index, index_length, SUHOSIN_G(array_index_whitelist)) != index_length) { @@ -127,11 +127,11 @@ static int check_fileupload_varname(char *varname TSRMLS_DC) } } } - - - index = strchr(index, '['); + + + index = strchr(index, '['); } - + /* Drop this variable if it exceeds the array depth limit */ if (SUHOSIN_G(max_array_depth) && SUHOSIN_G(max_array_depth) < depth) { suhosin_log(S_FILES, "configured request variable array depth limit exceeded - dropped variable '%s'", var); @@ -145,8 +145,8 @@ static int check_fileupload_varname(char *varname TSRMLS_DC) goto return_failure; } } - - + + /* Drop this variable if it is one of GLOBALS, _GET, _POST, ... */ /* This is to protect several silly scripts that do globalizing themself */ if (php_varname_check(var, var_len, 1 TSRMLS_CC) == FAILURE || suhosin_is_protected_varname(var, var_len)) { @@ -158,10 +158,10 @@ static int check_fileupload_varname(char *varname TSRMLS_DC) efree(var); return SUCCESS; - + return_failure: efree(var); - return FAILURE; + return FAILURE; } /* }}} */ @@ -200,54 +200,54 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS SDEBUG("rfc1867_filter %u", event); switch (event) { - case MULTIPART_EVENT_START: - case MULTIPART_EVENT_FORMDATA: - /* nothing todo */ - break; - - case MULTIPART_EVENT_FILE_START: - { - multipart_event_file_start *mefs = (multipart_event_file_start *) event_data; - + case MULTIPART_EVENT_START: + case MULTIPART_EVENT_FORMDATA: + /* nothing todo */ + break; + + case MULTIPART_EVENT_FILE_START: + { + multipart_event_file_start *mefs = (multipart_event_file_start *) event_data; + /* Drop if no more variables flag is set */ - if (SUHOSIN_G(no_more_uploads)) { - goto continue_with_failure; - } - + if (SUHOSIN_G(no_more_uploads)) { + goto continue_with_failure; + } + /* Drop this fileupload if the limit is reached */ if (SUHOSIN_G(upload_limit) && SUHOSIN_G(upload_limit) <= SUHOSIN_G(num_uploads)) { suhosin_log(S_FILES, "configured fileupload limit exceeded - file dropped"); if (!SUHOSIN_G(simulation)) { - SUHOSIN_G(no_more_uploads) = 1; - goto continue_with_failure; + SUHOSIN_G(no_more_uploads) = 1; + goto continue_with_failure; } } - - - if (check_fileupload_varname(mefs->name TSRMLS_CC) == FAILURE) { - goto continue_with_failure; - } - } - - break; - - case MULTIPART_EVENT_FILE_DATA: - - if (SUHOSIN_G(upload_disallow_elf)) { - multipart_event_file_data *mefd = (multipart_event_file_data *) event_data; - - if (mefd->offset == 0 && mefd->length > 10) { - if (mefd->data[0] == 0x7F && mefd->data[1] == 'E' && mefd->data[2] == 'L' && mefd->data[3] == 'F') { - suhosin_log(S_FILES, "uploaded file is an ELF executable - file dropped"); - if (!SUHOSIN_G(simulation)) { - goto continue_with_failure; - } - } - } - } - + + + if (check_fileupload_varname(mefs->name TSRMLS_CC) == FAILURE) { + goto continue_with_failure; + } + } + + break; + + case MULTIPART_EVENT_FILE_DATA: + + if (SUHOSIN_G(upload_disallow_elf)) { + multipart_event_file_data *mefd = (multipart_event_file_data *) event_data; + + if (mefd->offset == 0 && mefd->length > 10) { + if (mefd->data[0] == 0x7F && mefd->data[1] == 'E' && mefd->data[2] == 'L' && mefd->data[3] == 'F') { + suhosin_log(S_FILES, "uploaded file is an ELF executable - file dropped"); + if (!SUHOSIN_G(simulation)) { + goto continue_with_failure; + } + } + } + } + if (SUHOSIN_G(upload_disallow_binary)) { - + multipart_event_file_data *mefd = (multipart_event_file_data *) event_data; char *cp, *cpend; @@ -275,11 +275,11 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS } if (SUHOSIN_G(upload_remove_binary)) { - + multipart_event_file_data *mefd = (multipart_event_file_data *) event_data; size_t i, j; int n; - + for (i=0, j=0; ilength; i++) { if (mefd->data[i] >= 32 || isspace(mefd->data[i])) { mefd->data[j++] = mefd->data[i]; @@ -296,7 +296,7 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS #endif } mefd->data[j] = '\0'; - + SDEBUG("removing binary %zu %zu",i,j); /* IMPORTANT FOR DAISY CHAINING */ mefd->length = j; @@ -304,31 +304,31 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS *mefd->newlength = j; } } - - break; - - case MULTIPART_EVENT_FILE_END: - - if (SUHOSIN_G(upload_verification_script)) { - multipart_event_file_end *mefe = (multipart_event_file_end *) event_data; - char cmd[8192]; - FILE *in; - int first=1; + + break; + + case MULTIPART_EVENT_FILE_END: + + if (SUHOSIN_G(upload_verification_script)) { + multipart_event_file_end *mefe = (multipart_event_file_end *) event_data; + char cmd[8192]; + FILE *in; + int first=1; struct stat st; - char *sname = SUHOSIN_G(upload_verification_script); - - /* ignore files that will get deleted anyway */ - if (mefe->cancel_upload) { - break; - } - - /* ignore empty scriptnames */ - while (isspace(*sname)) ++sname; - if (*sname == 0) { - SUHOSIN_G(num_uploads)++; - break; - } - + char *sname = SUHOSIN_G(upload_verification_script); + + /* ignore files that will get deleted anyway */ + if (mefe->cancel_upload) { + break; + } + + /* ignore empty scriptnames */ + while (isspace(*sname)) ++sname; + if (*sname == 0) { + SUHOSIN_G(num_uploads)++; + break; + } + if (VCWD_STAT(sname, &st) < 0) { suhosin_log(S_FILES, "unable to find fileupload verification script %s - file dropped", sname); if (!SUHOSIN_G(simulation)) { @@ -343,29 +343,29 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS goto continue_with_failure; } else { goto continue_with_next; - } + } } - - ap_php_snprintf(cmd, sizeof(cmd), "%s %s 2>&1", sname, mefe->temp_filename); - - if ((in=VCWD_POPEN(cmd, "r"))==NULL) { - suhosin_log(S_FILES, "unable to execute fileupload verification script %s - file dropped", sname); - if (!SUHOSIN_G(simulation)) { - goto continue_with_failure; - } else { - goto continue_with_next; - } - } - - retval = FAILURE; - - /* read and forget the result */ - while (1) { - int readbytes = fread(cmd, 1, sizeof(cmd), in); - if (readbytes<=0) { - break; - } - if (first) { + + ap_php_snprintf(cmd, sizeof(cmd), "%s %s 2>&1", sname, mefe->temp_filename); + + if ((in=VCWD_POPEN(cmd, "r"))==NULL) { + suhosin_log(S_FILES, "unable to execute fileupload verification script %s - file dropped", sname); + if (!SUHOSIN_G(simulation)) { + goto continue_with_failure; + } else { + goto continue_with_next; + } + } + + retval = FAILURE; + + /* read and forget the result */ + while (1) { + int readbytes = fread(cmd, 1, sizeof(cmd), in); + if (readbytes<=0) { + break; + } + if (first) { if (strncmp(cmd, "sh: ", 4) == 0) { /* assume this is an error */ suhosin_log(S_FILES, "error while executing fileupload verification script %s - file dropped", sname); @@ -378,30 +378,30 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS retval = atoi(cmd) == 1 ? SUCCESS : FAILURE; first = 0; } - } - } - pclose(in); - } - - if (retval != SUCCESS) { - suhosin_log(S_FILES, "fileupload verification script disallows file - file dropped"); - if (!SUHOSIN_G(simulation)) { - goto continue_with_failure; - } - } - - SUHOSIN_G(num_uploads)++; - break; - - case MULTIPART_EVENT_END: - /* nothing todo */ - break; - - default: - /* unknown: return failure */ - goto continue_with_failure; + } + } + pclose(in); + } + + if (retval != SUCCESS) { + suhosin_log(S_FILES, "fileupload verification script disallows file - file dropped"); + if (!SUHOSIN_G(simulation)) { + goto continue_with_failure; + } + } + + SUHOSIN_G(num_uploads)++; + break; + + case MULTIPART_EVENT_END: + /* nothing todo */ + break; + + default: + /* unknown: return failure */ + goto continue_with_failure; } -continue_with_next: +continue_with_next: #if HAVE_RFC1867_CALLBACK if (php_rfc1867_callback != NULL) { return php_rfc1867_callback(event, event_data, extra TSRMLS_CC); @@ -409,7 +409,7 @@ continue_with_next: #endif return SUCCESS; continue_with_failure: - SUHOSIN_G(abort_request) = 1; + SUHOSIN_G(abort_request) = 1; return FAILURE; } -- cgit v1.3