From 1a3fd5eeb9a5859aefedb9302adb6ecd6a1873a7 Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Wed, 12 Oct 2016 14:57:47 +0200 Subject: comments and whitespace cleanup --- aes.c | 38 ++++++------ config.m4 | 1 - config.w32 | 2 - cookiecrypt.c | 23 +++---- crypt.c | 50 +++++++-------- ex_imp.c | 2 +- execute.c | 181 +++++++++++++++++++++++++++--------------------------- execute_rnd.c | 26 ++++---- header.c | 13 ++-- ifilter.c | 73 +++++++++++----------- log.c | 73 +++++++++++----------- memory_limit.c | 5 +- php_suhosin7.h | 28 ++++----- post_handler.c | 19 +++--- rfc1867.c | 2 - session.c | 47 +++++++------- sha256.c | 18 +++--- sha256.h | 2 - suhosin7.c | 50 ++++++++------- suhosin_rfc1867.h | 20 +++--- treat_data.c | 11 ++-- ufilter.c | 3 - 22 files changed, 322 insertions(+), 365 deletions(-) diff --git a/aes.c b/aes.c index b44d88b..ca56cd9 100644 --- a/aes.c +++ b/aes.c @@ -2,7 +2,7 @@ Written by Mike Scott 21st April 1999 mike@compapp.dcu.ie - An alternative faster version is implemented in MIRACL + An alternative faster version is implemented in MIRACL ftp://ftp.computing.dcu.ie/pub/crypto/miracl.zip Copyright (c) 1999 Mike Scott @@ -18,15 +18,15 @@ See rijndael documentation. The code follows the documentation as closely as possible, and where possible uses the same function and variable names. - Permission for free direct or derivative use is granted subject - to compliance with any conditions that the originators of the - algorithm place on its exploitation. + Permission for free direct or derivative use is granted subject + to compliance with any conditions that the originators of the + algorithm place on its exploitation. Inspiration from Brian Gladman's implementation is acknowledged. Written for clarity, rather than speed. Assumes long is 32 bit quantity. - Full implementation. + Full implementation. Endian indifferent. */ @@ -95,14 +95,14 @@ static WORD SubByte(WORD a) b[1]=fbsub[b[1]]; b[2]=fbsub[b[2]]; b[3]=fbsub[b[3]]; - return pack(b); + return pack(b); } static BYTE product(WORD x,WORD y) { /* dot product of two 4-byte arrays */ BYTE xb[4],yb[4]; unpack(x,xb); - unpack(y,yb); + unpack(y,yb); return bmul(xb[0],yb[0])^bmul(xb[1],yb[1])^bmul(xb[2],yb[2])^bmul(xb[3],yb[3]); } @@ -143,13 +143,13 @@ void suhosin_aes_gentables() ltab[0]=0; ptab[0]=1; ltab[1]=0; - ptab[1]=3; ltab[3]=1; + ptab[1]=3; ltab[3]=1; for (i=2;i<256;i++) { ptab[i]=ptab[i-1]^xtime(ptab[i-1]); ltab[ptab[i]]=i; } - + /* affine transformation:- each bit is xored with itself shifted one bit */ fbsub[0]=0x63; @@ -212,7 +212,7 @@ void suhosin_aes_gkey(int nb,int nk,char *key) } N=Nb*(Nr+1); - + for (i=j=0;i>8)])^ ROTL16((WORD)fbsub[(BYTE)(x[SUHOSIN7_G(fi)[m+1]]>>16)])^ ROTL24((WORD)fbsub[x[SUHOSIN7_G(fi)[m+2]]>>24]); - } + } for (i=j=0;i>8)])^ ROTL16((WORD)rbsub[(BYTE)(x[SUHOSIN7_G(ri)[m+1]]>>16)])^ ROTL24((WORD)rbsub[x[SUHOSIN7_G(ri)[m+2]]>>24]); - } + } for (i=j=0;i | +----------------------------------------------------------------------+ */ -/* - $Id: header.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -35,11 +32,11 @@ zend_string *suhosin_encrypt_single_cookie(char *name, int name_len, char *value { int l; - name = estrndup(name, name_len); + name = estrndup(name, name_len); name_len = php_url_decode(name, name_len); suhosin_normalize_varname(name); name_len = strlen(name); - + if ((SUHOSIN7_G(cookie_plainlist) && zend_hash_str_exists(SUHOSIN7_G(cookie_plainlist), name, name_len)) || (SUHOSIN7_G(cookie_plainlist) == NULL && SUHOSIN7_G(cookie_cryptlist) && !zend_hash_str_exists(SUHOSIN7_G(cookie_cryptlist), name, name_len))) { efree(name); @@ -48,7 +45,7 @@ zend_string *suhosin_encrypt_single_cookie(char *name, int name_len, char *value value = estrndup(value, value_len); value_len = php_url_decode(value, value_len); - + zend_string *d = suhosin_encrypt_string(value, value_len, name, name_len, key); zend_string *d_url = php_url_encode(ZSTR_VAL(d), ZSTR_LEN(d)); zend_string_release(d); @@ -63,7 +60,7 @@ char *suhosin_decrypt_single_cookie(char *name, int name_len, char *value, int v int name2_len = php_url_decode(name2, name_len); suhosin_normalize_varname(name2); name2_len = strlen(name2); - + if ((SUHOSIN7_G(cookie_plainlist) && zend_hash_str_exists(SUHOSIN7_G(cookie_plainlist), name2, name2_len)) || (SUHOSIN7_G(cookie_plainlist) == NULL && SUHOSIN7_G(cookie_cryptlist) && !zend_hash_str_exists(SUHOSIN7_G(cookie_cryptlist), name2, name2_len))) { // if (1) { @@ -75,10 +72,10 @@ char *suhosin_decrypt_single_cookie(char *name, int name_len, char *value, int v *out += value_len; return *out; } - + value = estrndup(value, value_len); value_len = php_url_decode(value, value_len); - + zend_string *d = suhosin_decrypt_string(value, value_len, name2, name2_len, key, SUHOSIN7_G(cookie_checkraddr)); if (d) { zend_string *d_url = php_url_encode(ZSTR_VAL(d), ZSTR_LEN(d)); @@ -93,7 +90,7 @@ char *suhosin_decrypt_single_cookie(char *name, int name_len, char *value, int v efree(name2); efree(value); - + return *out; } @@ -109,7 +106,7 @@ char *suhosin_cookie_decryptor(char *raw_cookie) // suhosin_generate_key(SUHOSIN7_G(cookie_cryptkey), SUHOSIN7_G(cookie_cryptua), SUHOSIN7_G(cookie_cryptdocroot), SUHOSIN7_G(cookie_cryptraddr), cryptkey); S7_GENERATE_KEY(cookie, cryptkey); // SDEBUG("cryptkey=%02x.%02x.%02x", cryptkey[0], cryptkey[1], cryptkey[2]); - + ret = decrypted = emalloc(strlen(raw_cookie)*4+1); raw_cookie = estrdup(raw_cookie); SUHOSIN7_G(raw_cookie) = estrdup(raw_cookie); @@ -138,10 +135,10 @@ char *suhosin_cookie_decryptor(char *raw_cookie) *decrypted++ = 0; ret = erealloc(ret, decrypted-ret); - + SUHOSIN7_G(decrypted_cookie) = ret; efree(raw_cookie); - + return ret; } /* }}} */ diff --git a/crypt.c b/crypt.c index 6daaa03..1bde7c7 100644 --- a/crypt.c +++ b/crypt.c @@ -41,7 +41,7 @@ static void suhosin_get_ipv4(char *buf) memset(buf, 0, 4); return; } - + for (i=0; i<4; i++) { if (raddr[0] == 0) { buf[i] = 0; @@ -59,11 +59,11 @@ zend_string *suhosin_encrypt_string(char *str, int len, char *var, int vlen, cha int padded_len, i, slen; unsigned char *crypted, *tmp; unsigned int check = 0x13579BDF; - + if (str == NULL) { return NULL; } - + if (len == 0) { return ZSTR_EMPTY_ALLOC(); } @@ -86,10 +86,10 @@ zend_string *suhosin_encrypt_string(char *str, int len, char *var, int vlen, cha check += check << 1; check ^= (unsigned char)str[i]; } - + /* store ip value */ suhosin_get_ipv4((char *)crypted + 4); - + /* store check value */ crypted[8] = check & 0xff; crypted[9] = (check >> 8) & 0xff; @@ -101,7 +101,7 @@ zend_string *suhosin_encrypt_string(char *str, int len, char *var, int vlen, cha crypted[13] = (len >> 8) & 0xff; crypted[14] = (len >> 16) & 0xff; crypted[15] = (len >> 24) & 0xff; - + for (i = 0, tmp = crypted; i < padded_len + 16; i += 16, tmp += 16) { if (i > 0) { int j; @@ -109,7 +109,7 @@ zend_string *suhosin_encrypt_string(char *str, int len, char *var, int vlen, cha } suhosin_aes_encrypt((char *)tmp); } - + zend_string *zs = php_base64_encode(crypted, padded_len+16); efree(crypted); // slen=strlen((char *)tmp); @@ -129,11 +129,11 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl SDEBUG("decrypting string |%s|", str); int i; unsigned int check = 0x13579BDF; - + if (str == NULL) { return NULL; } - + if (padded_len == 0) { return ZSTR_EMPTY_ALLOC(); } @@ -146,7 +146,7 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl case '_': str[i]='+'; break; } } - + zend_string *decrypted_zs = php_base64_decode((unsigned char *)str, padded_len); if (decrypted_zs == NULL) { return NULL; @@ -158,7 +158,7 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl if (len < 2*16 || (len % 16) != 0) { goto error_out; } - + unsigned char *tmp; for (i = len - 16, tmp = decrypted + i; i >= 0; i -= 16, tmp -= 16) { suhosin_aes_decrypt((char *)tmp); @@ -176,7 +176,7 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl o_len |= decrypted[13]; o_len <<= 8; o_len |= decrypted[12]; - + if (o_len < 0 || o_len > len-16) { goto error_out; } @@ -192,13 +192,13 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl check += check << 1; check ^= decrypted[16+i]; } - + /* check value */ int invalid = (decrypted[8] != (check & 0xff)) || (decrypted[9] != ((check >> 8) & 0xff)) || (decrypted[10] != ((check >> 16) & 0xff)) || (decrypted[11] != ((check >> 24) & 0xff)); - + /* check IP */ if (check_ra) { if (check_ra > 4) { @@ -210,16 +210,16 @@ zend_string *suhosin_decrypt_string(char *str, int padded_len, char *var, int vl goto error_out; } } - + if (invalid) { goto error_out; } - + memmove(decrypted, decrypted+16, o_len); decrypted[o_len] = 0; ZSTR_LEN(decrypted_zs) = o_len; - /* we do not realloc() here because 16 byte less - is simply not worth the overhead */ + /* we do not realloc() here because 16 byte less + is simply not worth the overhead */ return decrypted_zs; error_out: @@ -236,21 +236,21 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch char *_dr = NULL; char *_ra = NULL; PHP_SHA256_CTX ctx; - + if (ua) { _ua = suhosin_getenv(ZEND_STRL("HTTP_USER_AGENT")); } - + if (dr) { _dr = suhosin_getenv(ZEND_STRL("DOCUMENT_ROOT")); } - + if (raddr > 0) { _ra = suhosin_getenv(ZEND_STRL("REMOTE_ADDR")); } - + SDEBUG("KEY: %s - UA: %s - DR: %s - RA: %s", key,_ua,_dr,_ra); - + PHP_SHA256Init(&ctx); if (key == NULL || *key == 0) { PHP_SHA256Update(&ctx, (unsigned char*)ZEND_STRL("D3F4UL7")); @@ -269,7 +269,7 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch } else { long dots = 0; char *tmp = _ra; - + while (*tmp) { if (*tmp == '.') { dots++; @@ -284,6 +284,6 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch } PHP_SHA256Final((unsigned char *)cryptkey, &ctx); cryptkey[32] = 0; /* uhmm... not really a string */ - + return cryptkey; } diff --git a/ex_imp.c b/ex_imp.c index fd940ce..7ea0f29 100644 --- a/ex_imp.c +++ b/ex_imp.c @@ -108,7 +108,7 @@ static zend_always_inline int php_valid_var_name(char *var_name, size_t var_name if (suhosin_is_protected_varname(var_name, var_name_len)) { return 0; } - + return 1; } diff --git a/execute.c b/execute.c index 4b52fe4..698c637 100644 --- a/execute.c +++ b/execute.c @@ -17,7 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: execute.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ */ // #if 0 #ifdef HAVE_CONFIG_H #include "config.h" @@ -90,13 +89,13 @@ static int match_include_list(HashTable *ht, char *s, size_t slen) h2 = h2 == NULL ? NULL : h2 + 4; char *t = h = (h == NULL) ? h2 : ( (h2 == NULL) ? h : ( (h <= h2) ? h : h2 ) ); if (h == NULL) return -1; // no URL - + while (t > s && (isalnum(t[-1]) || t[-1]=='_' || t[-1]=='.')) { t--; } - + size_t tlen = slen - (t - s); - + zend_ulong num_key; zend_string *key; ZEND_HASH_FOREACH_KEY(ht, num_key, key) { @@ -137,7 +136,7 @@ static int suhosin_check_filename(char *s, int slen) char fname[MAXPATHLEN+1]; memcpy(fname, s, slen); - fname[slen] = 0; + fname[slen] = 0; s = (char *)fname; char *e = s + slen; @@ -145,7 +144,7 @@ static int suhosin_check_filename(char *s, int slen) if (slen != strlen(s)) { return SUHOSIN_CODE_TYPE_0FILE; } - + SDEBUG("fn=%s", s); /* disallow uploaded files */ if (SG(rfc1867_uploaded_files)) { @@ -153,7 +152,7 @@ static int suhosin_check_filename(char *s, int slen) return SUHOSIN_CODE_TYPE_UPLOADED; } } - + /* count number of directory traversals */ int traversal_conut = 0; for (int i = 0; i < slen-3; i++) { @@ -165,7 +164,7 @@ static int suhosin_check_filename(char *s, int slen) if (SUHOSIN7_G(executor_include_max_traversal) && traversal_conut > SUHOSIN7_G(executor_include_max_traversal)) { return SUHOSIN_CODE_TYPE_MANYDOTS; } - + SDEBUG("include wl=%p bl=%p", SUHOSIN7_G(include_whitelist), SUHOSIN7_G(include_blacklist)); /* no black or whitelist then disallow all */ if (SUHOSIN7_G(include_whitelist) == NULL && SUHOSIN7_G(include_blacklist) == NULL) { @@ -184,7 +183,7 @@ static int suhosin_check_filename(char *s, int slen) } } } - + check_filename_skip_lists: /* disallow writable files */ @@ -211,7 +210,7 @@ static void suhosin_check_codetype(zend_ulong code_type, char *filename) } } break; - + // case SUHOSIN_CODE_TYPE_REGEXP: // if (SUHOSIN7_G(executor_disable_emod)) { // suhosin_log(S_EXECUTOR|S_GETCALLER, "use of preg_replace() with /e modifier is forbidden by configuration"); @@ -220,7 +219,7 @@ static void suhosin_check_codetype(zend_ulong code_type, char *filename) // } // } // break; - + case SUHOSIN_CODE_TYPE_MBREGEXP: if (SUHOSIN7_G(executor_disable_emod)) { suhosin_log(S_EXECUTOR|S_GETCALLER, "use of /e modifier in replace function is forbidden by configuration"); @@ -229,13 +228,13 @@ static void suhosin_check_codetype(zend_ulong code_type, char *filename) } } break; - + case SUHOSIN_CODE_TYPE_ASSERT: break; - + case SUHOSIN_CODE_TYPE_CFUNC: break; - + case SUHOSIN_CODE_TYPE_LONGNAME: suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename is too long: %s", filename); suhosin_bailout(); @@ -245,27 +244,27 @@ static void suhosin_check_codetype(zend_ulong code_type, char *filename) suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename contains too many '../': %s", filename); suhosin_bailout(); break; - + case SUHOSIN_CODE_TYPE_UPLOADED: suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename is an uploaded file"); suhosin_bailout(); break; - + case SUHOSIN_CODE_TYPE_0FILE: suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename contains an ASCIIZ character"); suhosin_bailout(); break; - + case SUHOSIN_CODE_TYPE_WRITABLE: suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename is writable by PHP process: %s", filename); suhosin_bailout(); - break; + break; case SUHOSIN_CODE_TYPE_BLACKURL: suhosin_log(S_INCLUDE|S_GETCALLER, "Included URL is blacklisted: %s", filename); suhosin_bailout(); break; - + case SUHOSIN_CODE_TYPE_BADURL: suhosin_log(S_INCLUDE|S_GETCALLER, "Included URL is not allowed: %s", filename); suhosin_bailout(); @@ -295,11 +294,11 @@ static void suhosin_check_codetype(zend_ulong code_type, char *filename) ZEND_API static int (*old_zend_stream_open)(const char *filename, zend_file_handle *handle) = NULL; -// +// ZEND_API static int suhosin_zend_stream_open(const char *filename, zend_file_handle *handle) { zend_execute_data *execute_data = EG(current_execute_data); - + if ((execute_data != NULL) && (execute_data->opline != NULL) && (execute_data->opline->opcode == ZEND_INCLUDE_OR_EVAL)) { int filetype = suhosin_check_filename((char *)filename, strlen(filename)); suhosin_check_codetype(filetype, (char*)filename); @@ -319,11 +318,11 @@ static inline int suhosin_detect_codetype(zend_op_array *op_array) /* eval, assert, create_function, mb_ereg_replace */ if (op_array->type == ZEND_EVAL_CODE) { - + if (s == NULL) { return SUHOSIN_CODE_TYPE_UNKNOWN; } - + if (strstr(s, "eval()'d code") != NULL) { return SUHOSIN_CODE_TYPE_EVAL; } @@ -343,7 +342,7 @@ static inline int suhosin_detect_codetype(zend_op_array *op_array) if (strstr(s, "runtime-created function") != NULL) { return SUHOSIN_CODE_TYPE_CFUNC; } - + if (strstr(s, "Command line code") != NULL) { return SUHOSIN_CODE_TYPE_COMMANDLINE; } @@ -359,17 +358,17 @@ static inline int suhosin_detect_codetype(zend_op_array *op_array) if (strstr(s, "Command line end code") != NULL) { return SUHOSIN_CODE_TYPE_COMMANDLINE; } - + if (strstr(s, "suhosin internal code") != NULL) { return SUHOSIN_CODE_TYPE_SUHOSIN; } - + } else { return suhosin_check_filename(s, strlen(s)); } - + return SUHOSIN_CODE_TYPE_UNKNOWN; } @@ -384,19 +383,19 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) old_execute_ex(execute_data); return; } - + zend_op_array *new_op_array; int op_array_type;//, len; // char *fn; zval cs; zend_ulong orig_code_type; unsigned long *suhosin_flags = NULL; - + /* log variable dropping statistics */ if (SUHOSIN7_G(abort_request)) { - + SUHOSIN7_G(abort_request) = 0; /* we only want this to happen the first time */ - + if (SUHOSIN7_G(att_request_variables)-SUHOSIN7_G(cur_request_variables) > 0) { suhosin_log(S_VARS, "dropped %u request variables - (%u in GET, %u in POST, %u in COOKIE)", SUHOSIN7_G(att_request_variables)-SUHOSIN7_G(cur_request_variables), @@ -404,33 +403,33 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) SUHOSIN7_G(att_post_vars)-SUHOSIN7_G(cur_post_vars), SUHOSIN7_G(att_cookie_vars)-SUHOSIN7_G(cur_cookie_vars)); } - + // if (!SUHOSIN7_G(simulation) && SUHOSIN7_G(filter_action)) { - // + // // char *action = SUHOSIN7_G(filter_action); // long code = -1; - // + // // while (*action == ' ' || *action == '\t') action++; - // + // // if (*action >= '0' && *action <= '9') { // char *end = action; // while (*end && *end != ',' && *end != ';') end++; // code = zend_atoi(action, end-action); // action = end; // } - // + // // while (*action == ' ' || *action == '\t' || *action == ',' || *action == ';') action++; - // + // // if (*action) { - // + // // if (strncasecmp("http://", action, sizeof("http://")-1)==0 // || strncasecmp("https://", action, sizeof("https://")-1)==0) { // sapi_header_line ctr = {0}; - // + // // if (code == -1) { // code = 302; // } - // + // // ctr.line_len = spprintf(&ctr.line, 0, "Location: %s", action); // ctr.response_code = code; // sapi_header_op(SAPI_HEADER_REPLACE, &ctr); @@ -439,11 +438,11 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) // zend_file_handle file_handle; // zend_op_array *new_op_array; // zval *result = NULL; - // + // // if (code == -1) { // code = 200; // } - // + // // if (zend_stream_open(action, &file_handle) == SUCCESS) { // if (!file_handle.opened_path) { // file_handle.opened_path = estrndup(action, strlen(action)); @@ -456,7 +455,7 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) // zend_execute(new_op_array); // destroy_op_array(new_op_array); // efree(new_op_array); - // + // // if (!EG(exception)) // { // if (EG(return_value_ptr_ptr)) { @@ -472,24 +471,24 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) // } // } // } - // + // // sapi_header_op(SAPI_HEADER_SET_STATUS, (void *)code); // zend_bailout(); // } } - + // SDEBUG("%s %s", op_array->filename, op_array->function_name); - + SUHOSIN7_G(execution_depth)++; - + if (SUHOSIN7_G(max_execution_depth) && SUHOSIN7_G(execution_depth) > SUHOSIN7_G(max_execution_depth)) { suhosin_log(S_EXECUTOR|S_GETCALLER, "maximum execution depth reached - script terminated"); suhosin_bailout(); } - + // fn = (char *)execute_data->func->op_array.filename; // len = strlen(fn); - + orig_code_type = SUHOSIN7_G(in_code_type); if (execute_data->func->op_array.type == ZEND_EVAL_CODE) { SUHOSIN7_G(in_code_type) = SUHOSIN_EVAL; @@ -497,7 +496,7 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) // if (suhosin_zend_extension_entry.resource_number != -1) { // suhosin_flags = (unsigned long *) &execute_data->func->op_array.reserved[suhosin_zend_extension_entry.resource_number]; // SDEBUG("suhosin flags: %08lx", *suhosin_flags); - // + // // if (*suhosin_flags & SUHOSIN_FLAG_CREATED_BY_EVAL) { // SUHOSIN7_G(in_code_type) = SUHOSIN_EVAL; // } @@ -505,7 +504,7 @@ ZEND_API static void suhosin_execute_ex(zend_execute_data *execute_data) // goto not_evaled_code; // } // } - + if (zend_string_equals_literal(execute_data->func->op_array.filename, "eval()'d code")) { SUHOSIN7_G(in_code_type) = SUHOSIN_EVAL; } // else { @@ -523,7 +522,7 @@ not_evaled_code: /* if (SUHOSIN7_G(deactivate)) { goto continue_execution; } -*/ +*/ op_array_type = suhosin_detect_codetype(&execute_data->func->op_array); char *filename = execute_data->func->op_array.filename ? ZSTR_VAL(execute_data->func->op_array.filename) : ""; @@ -553,7 +552,7 @@ static suhosin_internal_function_handler ihandlers[] = { // { "mail", ih_mail, NULL, NULL, NULL }, // { "symlink", ih_symlink, NULL, NULL, NULL }, S7_IH_ENTRY0i(symlink) - + // random number functions S7_IH_ENTRY0i(srand) S7_IH_ENTRY0i(mt_srand) @@ -561,9 +560,9 @@ static suhosin_internal_function_handler ihandlers[] = { S7_IH_ENTRY0i(mt_rand) S7_IH_ENTRY0i(getrandmax) S7_IH_ENTRY0("mt_getrandmax", getrandmax) - + S7_IH_ENTRY0i(function_exists) - + /* Mysqli */ // { "mysqli::mysqli", ih_fixusername, (void *)2, NULL, NULL }, // { "mysqli_connect", ih_fixusername, (void *)2, NULL, NULL }, @@ -571,7 +570,7 @@ static suhosin_internal_function_handler ihandlers[] = { // { "mysqli_real_connect", ih_fixusername, (void *)3, NULL, NULL }, // { "mysqli_change_user", ih_fixusername, (void *)2, NULL, NULL }, // { "mysqli::change_user", ih_fixusername, (void *)1, NULL, NULL }, - + // { "mysqli::query", ih_querycheck, (void *)1, (void *)1, NULL }, // { "mysqli_query", ih_querycheck, (void *)2, (void *)1, NULL }, // { "mysqli::multi_query", ih_querycheck, (void *)1, (void *)1, NULL }, @@ -586,14 +585,14 @@ static suhosin_internal_function_handler ihandlers[] = { // { "mysqli_master_query", ih_querycheck, (void *)2, (void *)1, NULL }, // { "mysqli_slave_query", ih_querycheck, (void *)2, (void *)1, NULL }, // ---- - + /* Mysql API - deprecated in PHP 5.5 */ // { "mysql_connect", ih_fixusername, (void *)2, NULL, NULL }, // { "mysql_pconnect", ih_fixusername, (void *)2, NULL, NULL }, // { "mysql_query", ih_querycheck, (void *)1, (void *)1, NULL }, // { "mysql_db_query", ih_querycheck, (void *)2, (void *)1, NULL }, // { "mysql_unbuffered_query", ih_querycheck, (void *)1, (void *)1, NULL }, - + #ifdef SUHOSIN7_EXPERIMENTAL /* MaxDB */ // { "maxdb::maxdb", ih_fixusername, (void *)2, NULL, NULL }, @@ -602,7 +601,7 @@ static suhosin_internal_function_handler ihandlers[] = { // { "maxdb_real_connect", ih_fixusername, (void *)3, NULL, NULL }, // { "maxdb::change_user", ih_fixusername, (void *)1, NULL, NULL }, // { "maxdb_change_user", ih_fixusername, (void *)2, NULL, NULL }, - // + // // { "maxdb_master_query", ih_querycheck, (void *)2, NULL, NULL }, // { "maxdb::multi_query", ih_querycheck, (void *)1, NULL, NULL }, // { "maxdb_multi_query", ih_querycheck, (void *)2, NULL, NULL }, @@ -621,7 +620,7 @@ static suhosin_internal_function_handler ihandlers[] = { // { "pdo::query", ih_querycheck, (void *)1, NULL, NULL }, // { "pdo::prepare", ih_querycheck, (void *)1, NULL, NULL }, // { "pdo::exec", ih_querycheck, (void *)1, NULL, NULL }, - + /* Oracle OCI8 */ // { "ocilogon", ih_fixusername, (void *)1, NULL, NULL }, // { "ociplogon", ih_fixusername, (void *)1, NULL, NULL }, @@ -639,7 +638,7 @@ static suhosin_internal_function_handler ihandlers[] = { /* Informix */ // { "ifx_connect", ih_fixusername, (void *)2, NULL, NULL }, // { "ifx_pconnect", ih_fixusername, (void *)2, NULL, NULL }, - // + // /* Firebird/InterBase */ // { "ibase_connect", ih_fixusername, (void *)2, NULL, NULL }, // { "ibase_pconnect", ih_fixusername, (void *)2, NULL, NULL }, @@ -671,21 +670,21 @@ ZEND_API static void suhosin_execute_internal(zend_execute_data *execute_data, z suhosin_bailout(); return; } - + zend_function *func = execute_data->func; if (func == NULL) { suhosin_log(S_EXECUTOR|S_GETCALLER, "execution without function context. something is wrong."); suhosin_bailout(); } - - + + // zval *return_value; // zval **return_value_ptr; // zval *this_ptr; int ht = 0; int retval = SUCCESS; - + // if (fci) { // return_value = *fci->retval_ptr_ptr; // return_value_ptr = fci->retval_ptr_ptr; @@ -698,17 +697,17 @@ ZEND_API static void suhosin_execute_internal(zend_execute_data *execute_data, z // return_value_ptr = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL; // this_ptr = execute_data_ptr->object; // ht = execute_data->opline->extended_value; - // } + // } // char *lcname; // int function_name_strlen, free_lcname = 0; // zend_class_entry *ce = NULL; // internal_function_handler *ih; - // + // // ce = ((zend_internal_function *) execute_data_ptr->function_state.function)->scope; // lcname = (char *)((zend_internal_function *) execute_data_ptr->function_state.function)->function_name; // function_name_strlen = strlen(lcname); - + /* handle methodcalls correctly */ // if (ce != NULL) { // char *tmp = (char *) emalloc(function_name_strlen + 2 + ce->name_length + 1); @@ -730,11 +729,11 @@ ZEND_API static void suhosin_execute_internal(zend_execute_data *execute_data, z // no function name -> skip whitelists/blacklists goto execute_internal_continue; } - + SDEBUG("function: [%s]/%zu", ZSTR_VAL(function_name), ZSTR_LEN(function_name)) ; if (SUHOSIN7_G(in_code_type) == SUHOSIN_EVAL) { - + if (SUHOSIN7_G(eval_whitelist) != NULL) { if (!zend_hash_exists(SUHOSIN7_G(eval_whitelist), function_name)) { suhosin_log(S_EXECUTOR|S_GETCALLER, "eval'd function not whitelisted: %s()", ZSTR_VAL(function_name)); @@ -755,7 +754,7 @@ ZEND_API static void suhosin_execute_internal(zend_execute_data *execute_data, z } } } - + if (SUHOSIN7_G(func_whitelist) != NULL) { if (!zend_hash_exists(SUHOSIN7_G(func_whitelist), function_name)) { suhosin_log(S_EXECUTOR|S_GETCALLER, "function not whitelisted: %s()", ZSTR_VAL(function_name)); @@ -775,19 +774,19 @@ ZEND_API static void suhosin_execute_internal(zend_execute_data *execute_data, z } } } - + suhosin_internal_function_handler *ih; if ((ih = zend_hash_find_ptr(&ihandler_table, function_name))) { void *handler = execute_data->func->internal_function.handler; - + if (handler != ZEND_FN(display_disabled_function)) { retval = ih->handler(S7_IH_HANDLER_PARAM_PASSTHRU); } - + } execute_internal_continue: - + if (retval == SUCCESS) { old_execute_internal(execute_data, return_value); } @@ -813,13 +812,13 @@ execute_internal_bailout: // if (zo_set_oe_ex != NULL) { // return ZEND_HASH_APPLY_STOP; // } -// +// // if (extension->handle != NULL) { -// +// // zo_set_oe_ex = (void *)DL_FETCH_SYMBOL(extension->handle, "zend_optimizer_set_oe_ex"); -// +// // } -// +// // return 0; // } /* }}} */ @@ -831,29 +830,29 @@ void suhosin_hook_execute() { old_execute_ex = zend_execute_ex; zend_execute_ex = suhosin_execute_ex; - + /* old_compile_file = zend_compile_file; zend_compile_file = suhosin_compile_file; */ // #if ZO_COMPATIBILITY_HACK_TEMPORARY_DISABLED -// if (zo_set_oe_ex == NULL) { +// if (zo_set_oe_ex == NULL) { // zo_set_oe_ex = (void *)DL_FETCH_SYMBOL(NULL, "zend_optimizer_set_oe_ex"); // } -// if (zo_set_oe_ex == NULL) { +// if (zo_set_oe_ex == NULL) { // zend_llist_apply(&zend_extensions, (llist_apply_func_t)function_lookup); // } -// +// // if (zo_set_oe_ex != NULL) { // old_execute_ZO = zo_set_oe_ex(suhosin_execute_ZO); // } // #endif - + old_execute_internal = zend_execute_internal; if (old_execute_internal == NULL) { old_execute_internal = execute_internal; } zend_execute_internal = suhosin_execute_internal; - + /* register internal function handlers */ zend_hash_init(&ihandler_table, 16, NULL, NULL, 1); suhosin_internal_function_handler *ih = &ihandlers[0]; @@ -863,8 +862,8 @@ void suhosin_hook_execute() zend_hash_str_add_ptr(&ihandler_table, ih->name, strlen(ih->name), ih); ih++; } - - + + /* Add additional protection layer, that SHOULD catch ZEND_INCLUDE_OR_EVAL *before* the engine tries to execute */ @@ -872,7 +871,7 @@ void suhosin_hook_execute() old_zend_stream_open = zend_stream_open_function; } zend_stream_open_function = suhosin_zend_stream_open; - + } /* }}} */ @@ -888,7 +887,7 @@ void suhosin_unhook_execute() // #endif zend_execute_ex = old_execute_ex; - + /* zend_compile_file = old_compile_file; */ if (old_execute_internal == execute_internal) { @@ -896,10 +895,10 @@ void suhosin_unhook_execute() } zend_execute_internal = old_execute_internal; zend_hash_clean(&ihandler_table); - + /* remove zend_open protection */ zend_stream_open_function = old_zend_stream_open; - + } /* }}} */ diff --git a/execute_rnd.c b/execute_rnd.c index e2f6016..10d7d5a 100644 --- a/execute_rnd.c +++ b/execute_rnd.c @@ -44,7 +44,7 @@ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, Copyright (C) 2000 - 2003, Richard J. Wagner - All rights reserved. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -57,8 +57,8 @@ notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -187,14 +187,14 @@ static php_uint32 suhosin_mt_rand() { /* Pull a 32-bit integer from the generator state Every other access function simply transforms the numbers extracted here */ - + register php_uint32 s1; if (SUHOSIN7_G(mt_left) == 0) { suhosin_mt_reload(SUHOSIN7_G(mt_state), &SUHOSIN7_G(mt_next), &SUHOSIN7_G(mt_left)); } --SUHOSIN7_G(mt_left); - + s1 = *SUHOSIN7_G(mt_next)++; s1 ^= (s1 >> 11); s1 ^= (s1 << 7) & 0x9d2c5680U; @@ -263,7 +263,7 @@ static void SUHOSIN7_Gen_entropy(php_uint32 *entropybuf) */ static void suhosin_srand_auto() { - php_uint32 seed[8]; + php_uint32 seed[8]; SUHOSIN7_Gen_entropy(&seed[0]); suhosin_mt_init_by_array(seed, 8, SUHOSIN7_G(r_state)); @@ -278,7 +278,7 @@ static void suhosin_srand_auto() */ static void suhosin_mt_srand_auto() { - php_uint32 seed[8]; + php_uint32 seed[8]; SUHOSIN7_Gen_entropy(&seed[0]); suhosin_mt_init_by_array(seed, 8, SUHOSIN7_G(mt_state)); @@ -309,14 +309,14 @@ static php_uint32 suhosin_rand() { /* Pull a 32-bit integer from the generator state Every other access function simply transforms the numbers extracted here */ - + register php_uint32 s1; if (SUHOSIN7_G(r_left) == 0) { suhosin_mt_reload(SUHOSIN7_G(r_state), &SUHOSIN7_G(r_next), &SUHOSIN7_G(r_left)); } --SUHOSIN7_G(r_left); - + s1 = *SUHOSIN7_G(r_next)++; s1 ^= (s1 >> 11); s1 ^= (s1 << 7) & 0x9d2c5680U; @@ -334,7 +334,7 @@ S7_IH_FUNCTION(srand) SUHOSIN7_G(r_is_seeded) = 0; return 1; } - + if (zend_parse_parameters(argc, "|l", &seed) == FAILURE) { return 1; } @@ -356,7 +356,7 @@ S7_IH_FUNCTION(mt_srand) SUHOSIN7_G(mt_is_seeded) = 0; return 1; } - + if (zend_parse_parameters(argc, "|l", &seed) == FAILURE) { return 1; } @@ -377,7 +377,7 @@ S7_IH_FUNCTION(mt_rand) long number; if (argc != 0 && zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) { - return (1); + return (1); } if (!SUHOSIN7_G(mt_is_seeded)) { @@ -401,7 +401,7 @@ S7_IH_FUNCTION(rand) long number; if (argc != 0 && zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) { - return (1); + return (1); } if (!SUHOSIN7_G(r_is_seeded)) { diff --git a/header.c b/header.c index b7ce010..f747bbd 100644 --- a/header.c +++ b/header.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: header.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -41,9 +38,9 @@ static int suhosin_header_handler(sapi_header_struct *sapi_header, sapi_header_o if (op != SAPI_HEADER_ADD && op != SAPI_HEADER_REPLACE) { goto suhosin_skip_header_handling; } - + if (sapi_header && sapi_header->header) { - + char *tmp = sapi_header->header; for (int i = 0; i < sapi_header->header_len; i++, tmp++) { @@ -55,7 +52,7 @@ static int suhosin_header_handler(sapi_header_struct *sapi_header, sapi_header_o } if (SUHOSIN7_G(allow_multiheader)) { continue; - } else if ((tmp[0] == '\r' && (tmp[1] != '\n' || i == 0)) || + } else if ((tmp[0] == '\r' && (tmp[1] != '\n' || i == 0)) || (tmp[0] == '\n' && (i == sapi_header->header_len-1 || i == 0 || (tmp[1] != ' ' && tmp[1] != '\t')))) { suhosin_log(S_MISC, "%s() - wanted to send multiple HTTP headers at once", suhosin_get_active_function_name()); if (!SUHOSIN7_G(simulation)) { @@ -99,8 +96,8 @@ static int suhosin_header_handler(sapi_header_struct *sapi_header, sapi_header_o } vlen = end-value; - zend_string *zs_val = suhosin_encrypt_single_cookie(name, nlen, value, vlen, (char *)cryptkey); - + zend_string *zs_val = suhosin_encrypt_single_cookie(name, nlen, value, vlen, (char *)cryptkey); + len = sizeof("Set-Cookie: ")-1 + nlen + 1 + ZSTR_LEN(zs_val) + rend-end; tmp = emalloc(len + 1); tlen = sprintf(tmp, "Set-Cookie: %.*s=%s", nlen, name, ZSTR_VAL(zs_val)); diff --git a/ifilter.c b/ifilter.c index a8fa8e2..cdef00c 100644 --- a/ifilter.c +++ b/ifilter.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: ifilter.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -67,12 +64,12 @@ size_t suhosin_strncspn(const char *input, size_t n, const char *reject) void suhosin_normalize_varname(char *varname) { char *s=varname, *index=NULL, *indexend=NULL, *p; - + /* overjump leading space */ while (*s == ' ') { s++; } - + /* and remove it */ if (s != varname) { memmove(varname, s, strlen(s)+1); @@ -104,7 +101,7 @@ void suhosin_normalize_varname(char *varname) } indexend = strchr(index, ']'); indexend = indexend ? indexend + 1 : index + strlen(index); - + if (s != index) { memmove(s, index, strlen(index)+1); s += indexend-index; @@ -117,7 +114,7 @@ void suhosin_normalize_varname(char *varname) index = s; } else { index = NULL; - } + } } *s++='\0'; } @@ -155,7 +152,7 @@ static void suhosin_server_strip(HashTable *arr, char *key, int klen) Z_TYPE_P(zv) != IS_STRING) { return; } - + t = (unsigned char *)Z_STRVAL_P(zv); // SDEBUG() for (; *t; t++) { @@ -178,7 +175,7 @@ static void suhosin_server_encode(HashTable *arr, char *key, int klen) Z_TYPE_P(zv) != IS_STRING) { return; } - + unsigned char *orig = (unsigned char *)Z_STRVAL_P(zv); unsigned char *t; for (t = orig; *t; t++) { @@ -186,12 +183,12 @@ static void suhosin_server_encode(HashTable *arr, char *key, int klen) extra += 2; } } - + /* no extra bytes required */ if (extra == 0) { return; } - + size_t dest_len = t - orig + 1 + extra; unsigned char dest[dest_len]; unsigned char *n = dest; @@ -256,7 +253,7 @@ void suhosin_register_server_variables(zval *track_vars_array) if (failure) { suhosin_log(S_VARS, "Attacker tried to overwrite a superglobal through a HTTP header"); } - + if (SUHOSIN7_G(raw_cookie)) { zval z; ZVAL_STRING(&z, SUHOSIN7_G(raw_cookie)); @@ -269,7 +266,7 @@ void suhosin_register_server_variables(zval *track_vars_array) efree(SUHOSIN7_G(decrypted_cookie)); SUHOSIN7_G(decrypted_cookie) = NULL; } - + if (SUHOSIN7_G(server_encode)) { /* suhosin_server_encode(svars, ZEND_STRL("argv")); */ suhosin_server_encode(svars, ZEND_STRL("REQUEST_URI")); @@ -332,7 +329,7 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } return 1; } - + /* Drop this variable if the limit is now reached */ switch (arg) { case PARSE_GET: @@ -363,7 +360,7 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } break; } - + /* Drop this variable if it begins with whitespace which is disallowed */ // SDEBUG("checking '%c'", *var); if (isspace(*var)) { @@ -394,7 +391,7 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } } // else { SDEBUG("not WS");} - + /* Drop this variable if it exceeds the value length limit */ if (SUHOSIN7_G(max_value_length) && SUHOSIN7_G(max_value_length) < val_len) { suhosin_log(S_VARS, "configured request variable value length limit exceeded - dropped variable '%s'", var); @@ -420,15 +417,15 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } break; } - + /* Normalize the variable name */ suhosin_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 (SUHOSIN7_G(max_varname_length) && SUHOSIN7_G(max_varname_length) < var_len) { suhosin_log(S_VARS, "configured request variable name length limit exceeded - dropped variable '%s'", var); @@ -470,51 +467,51 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } break; } - + /* 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; - + /* max. array index length */ if (SUHOSIN7_G(max_array_index_length) && SUHOSIN7_G(max_array_index_length) < index_length) { suhosin_log(S_VARS, "configured request variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN7_G(simulation)) { return 0; } - } + } switch (arg) { case PARSE_GET: if (SUHOSIN7_G(max_get_array_index_length) && SUHOSIN7_G(max_get_array_index_length) < index_length) { suhosin_log(S_VARS, "configured GET variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN7_G(simulation)) { return 0; } - } + } break; case PARSE_COOKIE: if (SUHOSIN7_G(max_cookie_array_index_length) && SUHOSIN7_G(max_cookie_array_index_length) < index_length) { suhosin_log(S_VARS, "configured COOKIE variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN7_G(simulation)) { return 0; } - } + } break; case PARSE_POST: if (SUHOSIN7_G(max_post_array_index_length) && SUHOSIN7_G(max_post_array_index_length) < index_length) { suhosin_log(S_VARS, "configured POST variable array index length limit exceeded - dropped variable '%s'", var); if (!SUHOSIN7_G(simulation)) { return 0; } - } + } break; } - + /* index whitelist/blacklist */ if (SUHOSIN7_G(array_index_whitelist) && *(SUHOSIN7_G(array_index_whitelist))) { if (suhosin_strnspn(index, index_length, SUHOSIN7_G(array_index_whitelist)) != index_length) { @@ -527,10 +524,10 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) if (!SUHOSIN7_G(simulation)) { return 0; } } } - + index = strchr(index, '['); } - + /* Drop this variable if it exceeds the array depth limit */ if (SUHOSIN7_G(max_array_depth) && SUHOSIN7_G(max_array_depth) < depth) { suhosin_log(S_VARS, "configured request variable array depth limit exceeded - dropped variable '%s'", var); @@ -558,9 +555,9 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) } /* Check if variable value is truncated by a \0 */ - + if (val && *val && val_len != strnlen(*val, val_len)) { - + if (SUHOSIN7_G(disallow_nul)) { suhosin_log(S_VARS, "ASCII-NUL chars not allowed within request variables - dropped variable '%s'", var); if (!SUHOSIN7_G(simulation)) { return 0; } @@ -586,7 +583,7 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) break; } } - + /* Drop this variable if it is one of GLOBALS, _GET, _POST, ... */ /* This is to protect several silly scripts that do globalizing themself */ if (suhosin_is_protected_varname(var, var_len)) { @@ -607,7 +604,7 @@ static SAPI_INPUT_FILTER_FUNC(suhosin_input_filter) SUHOSIN7_G(cur_post_vars)++; break; } - + if (new_val_len) { *new_val_len = val_len; } @@ -625,7 +622,7 @@ SAPI_INPUT_FILTER_FUNC(suhosin_input_filter_wrapper) // SDEBUG("ifilter arg=%d var=%s do_not_scan=%d already_scanned=%d", arg, var, SUHOSIN7_G(do_not_scan), already_scanned); // SDEBUG("ifilter arg=%d var=%s do_not_scan=%d", arg, var, SUHOSIN7_G(do_not_scan)); SDEBUG("ifilter arg=%d var=%s", arg, var); - + // if (SUHOSIN7_G(do_not_scan)) { // SDEBUG("do_not_scan"); // if (new_val_len) { @@ -633,7 +630,7 @@ SAPI_INPUT_FILTER_FUNC(suhosin_input_filter_wrapper) // } // return 1; // } - + // if (!already_scanned) { if (suhosin_input_filter(arg, var, val, val_len, new_val_len) == 0) { SUHOSIN7_G(abort_request)=1; diff --git a/log.c b/log.c index 67e37b4..fe6d824 100644 --- a/log.c +++ b/log.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: log.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -82,7 +79,7 @@ static HANDLE log_source = 0; // case S_VARS: // return "VARS"; // default: -// return "UNKNOWN"; +// return "UNKNOWN"; // } // } @@ -129,7 +126,7 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) volatile unsigned int *x = 0; volatile int y = *x; } - + if (SUHOSIN7_G(log_use_x_forwarded_for)) { ip_address = suhosin_getenv("HTTP_X_FORWARDED_FOR", 20); if (ip_address == NULL) { @@ -141,8 +138,8 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) ip_address = "REMOTE_ADDR not set"; } } - - + + va_start(ap, fmt); ap_php_vsnprintf(error, sizeof(error), fmt, ap); va_end(ap); @@ -150,13 +147,13 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) if (error[i] < 32) error[i] = '.'; i++; } - + if (SUHOSIN7_G(simulation)) { alertstring = "ALERT-SIMULATION"; } else { alertstring = "ALERT"; } - + if (zend_is_executing()) { // zend_execute_data *exdata = EG(current_execute_data); // if (exdata) { @@ -182,25 +179,25 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) } ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname); } - + /* Syslog-Logging disabled? */ // if (((SUHOSIN7_G(log_syslog)|S_INTERNAL) & loglevel)==0) { // goto log_file; -// } -// +// } +// // #if defined(AF_UNIX) // ap_php_snprintf(error, sizeof(error), "<%u>suhosin[%u]: %s\n", (unsigned int)(SUHOSIN7_G(log_syslog_facility)|SUHOSIN7_G(log_syslog_priority)),getpid(),buf); -// +// // s = socket(AF_UNIX, SOCK_DGRAM, 0); // if (s == -1) { // goto log_file; // } -// +// // memset(&saun, 0, sizeof(saun)); // saun.sun_family = AF_UNIX; // strcpy(saun.sun_path, SYSLOG_PATH); // /*saun.sun_len = sizeof(saun);*/ -// +// // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); // if (r) { // close(s); @@ -208,25 +205,25 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) // if (s == -1) { // goto log_file; // } -// +// // memset(&saun, 0, sizeof(saun)); // saun.sun_family = AF_UNIX; // strcpy(saun.sun_path, SYSLOG_PATH); // /*saun.sun_len = sizeof(saun);*/ -// +// // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); -// if (r) { +// if (r) { // close(s); // goto log_file; // } // } // send(s, error, strlen(error), 0); -// +// // close(s); // #endif // #ifdef PHP_WIN32 // ap_php_snprintf(error, sizeof(error), "suhosin[%u]: %s", getpid(),buf); -// +// // switch (SUHOSIN7_G(log_syslog_priority)) { /* translate UNIX type into NT type */ // case 1: /*LOG_ALERT:*/ // etype = EVENTLOG_ERROR_TYPE; @@ -244,14 +241,14 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) // log_source = RegisterEventSource(NULL, "Suhosin-" SUHOSIN_EXT_VERSION); // } // ReportEvent(log_source, etype, (unsigned short) SUHOSIN7_G(log_syslog_priority), evid, NULL, 1, 0, strs, NULL); -// +// // #endif log_file: /* File-Logging disabled? */ if ((SUHOSIN7_G(log_file) & loglevel)==0) { goto log_sapi; } - + if (!SUHOSIN7_G(log_filename) || !SUHOSIN7_G(log_filename)[0]) { goto log_sapi; } @@ -300,20 +297,20 @@ log_sapi: // FILE *in; // int space; // struct stat st; -// +// // char *sname = SUHOSIN7_G(log_scriptname); // while (isspace(*sname)) ++sname; // if (*sname == 0) goto log_phpscript; -// +// // if (VCWD_STAT(sname, &st) < 0) { // suhosin_log(S_INTERNAL, "unable to find logging shell script %s - file dropped", sname); // goto log_phpscript; // } // if (access(sname, X_OK|R_OK) < 0) { // suhosin_log(S_INTERNAL, "logging shell script %s is not executable - file dropped", sname); -// goto log_phpscript; +// goto log_phpscript; // } -// +// // /* TODO: clean up this code to calculate size of output dynamically */ // ap_php_snprintf(cmd, sizeof(cmd) - 20, "%s %s \'", sname, loglevel2string(loglevel)); // space = sizeof(cmd) - strlen(cmd) - 20; @@ -341,7 +338,7 @@ log_sapi: // *cmdpos++ = '&'; // *cmdpos++ = '1'; // *cmdpos = 0; -// +// // if ((in=VCWD_POPEN(cmd, "r"))==NULL) { // suhosin_log(S_INTERNAL, "Unable to execute logging shell script: %s", sname); // goto log_phpscript; @@ -366,10 +363,10 @@ log_sapi: // zend_file_handle file_handle; // zend_op_array *new_op_array; // zval *result = NULL; -// +// // long orig_execution_depth = SUHOSIN7_G(execution_depth); // char *orig_basedir = PG(open_basedir); -// +// // char *phpscript = SUHOSIN7_G(log_phpscriptname); // SDEBUG("scriptname %s", SUHOSIN7_G(log_phpscriptname)); // if (zend_stream_open(phpscript, &file_handle) == SUCCESS) { @@ -381,34 +378,34 @@ log_sapi: // if (new_op_array) { // HashTable *active_symbol_table = EG(active_symbol_table); // zval *zerror, *zerror_class; -// +// // if (active_symbol_table == NULL) { // active_symbol_table = &EG(symbol_table); // } // EG(return_value_ptr_ptr) = &result; // EG(active_op_array) = new_op_array; -// +// // MAKE_STD_ZVAL(zerror); // MAKE_STD_ZVAL(zerror_class); // ZVAL_STRING(zerror, buf, 1); // ZVAL_LONG(zerror_class, loglevel); -// +// // zend_hash_update(active_symbol_table, "SUHOSIN_ERROR", sizeof("SUHOSIN_ERROR"), (void **)&zerror, sizeof(zval *), NULL); // zend_hash_update(active_symbol_table, "SUHOSIN_ERRORCLASS", sizeof("SUHOSIN_ERRORCLASS"), (void **)&zerror_class, sizeof(zval *), NULL); -// +// // SUHOSIN7_G(execution_depth) = 0; // if (SUHOSIN7_G(log_phpscript_is_safe)) { // PG(open_basedir) = NULL; // } -// +// // zend_execute(new_op_array); -// +// // SUHOSIN7_G(execution_depth) = orig_execution_depth; // PG(open_basedir) = orig_basedir; -// +// // destroy_op_array(new_op_array); // efree(new_op_array); -// +// // if (!EG(exception)) // { // if (EG(return_value_ptr_ptr)) { @@ -425,7 +422,7 @@ log_sapi: // return; // } // } -// +// } diff --git a/memory_limit.c b/memory_limit.c index 2a7a114..63c09b6 100644 --- a/memory_limit.c +++ b/memory_limit.c @@ -16,9 +16,6 @@ | Author: Stefan Esser and others | +----------------------------------------------------------------------+ */ -/* - $Id: memory_limit.c $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -84,7 +81,7 @@ void suhosin_hook_memory_limit() /* replace OnUpdateMemoryLimit handler */ ini_entry->on_modify = suhosin_OnChangeMemoryLimit; } - + } diff --git a/php_suhosin7.h b/php_suhosin7.h index 6c515ba..1398a36 100644 --- a/php_suhosin7.h +++ b/php_suhosin7.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #pragma once extern zend_module_entry suhosin7_module_entry; @@ -56,7 +54,7 @@ extern zend_module_entry suhosin7_module_entry; {FILE *f;f=fopen(SUHOSIN_LOG, "a+");if(f){fprintf(f,"[%u] %s:%u %s #> ",getpid(), __FILE__, __LINE__, __func__);fprintf(f, msg);fprintf(f,"\n");fclose(f);}} #else #define SDEBUG(msg...) -#endif +#endif #endif /* -------------- */ @@ -128,13 +126,13 @@ protected_varname: ZEND_BEGIN_MODULE_GLOBALS(suhosin7) zend_bool protectkey; - + zend_bool simulation; // zend_bool stealth; // zend_bool already_scanned; zend_bool abort_request; - // - + // + /* executor */ zend_ulong in_code_type; zend_bool executor_allow_symlink; @@ -203,7 +201,7 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) zend_long max_post_array_index_length; zend_bool disallow_post_nul; zend_bool disallow_post_ws; - + /* fileupload */ zend_long upload_max_newlines; zend_long upload_limit; @@ -235,7 +233,7 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) BYTE fi[24],ri[24]; WORD fkey[120]; WORD rkey[120]; - + zend_bool session_encrypt; char* session_cryptkey; zend_bool session_cryptua; @@ -260,10 +258,10 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) zend_bool coredump; // zend_bool apc_bug_workaround; // zend_bool do_not_scan; - // + // zend_bool server_encode; zend_bool server_strip; - // + // zend_bool disable_display_errors; /* random number generator */ @@ -275,11 +273,11 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) php_uint32 mt_state[625]; php_uint32 *mt_next; int mt_left; - + char *seedingkey; zend_bool reseed_every_request; - // - zend_bool r_is_seeded; + // + zend_bool r_is_seeded; zend_bool mt_is_seeded; @@ -287,7 +285,7 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) zend_long memory_limit; zend_long hard_memory_limit; - + /* PERDIR Handling */ @@ -333,7 +331,7 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) // long sql_opencomment; // long sql_union; // long sql_mselect; - + // int (*old_php_body_write)(const char *str, unsigned int str_length); ZEND_END_MODULE_GLOBALS(suhosin7) diff --git a/post_handler.c b/post_handler.c index 1a2374c..3b8ca47 100644 --- a/post_handler.c +++ b/post_handler.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: post_handler.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -49,7 +46,7 @@ static void suhosin_post_handler_modification(sapi_post_entry *spe) } // static PHP_INI_MH((*old_OnUpdate_mbstring_encoding_translation)) = NULL; -// +// // /* {{{ static PHP_INI_MH(suhosin_OnUpdate_mbstring_encoding_translation) */ // static PHP_INI_MH(suhosin_OnUpdate_mbstring_encoding_translation) // { @@ -58,12 +55,12 @@ static void suhosin_post_handler_modification(sapi_post_entry *spe) // char *base = (char *) mh_arg2; // #else // char *base; -// +// // base = (char *) ts_resource(*((int *) mh_arg2)); // #endif -// +// // p = (zend_bool *) (base+(size_t) mh_arg1); -// +// // if (new_value_length == 2 && strcasecmp("on", new_value) == 0) { // *p = (zend_bool) 1; // } @@ -96,7 +93,7 @@ void suhosin_hook_post_handlers() { HashTable tempht; // zend_ini_entry *ini_entry; - + sapi_unregister_post_entry(&suhosin_post_entries[0]); // sapi_unregister_post_entry(&suhosin_post_entries[1]); sapi_register_post_entries(suhosin_post_entries); @@ -109,7 +106,7 @@ void suhosin_hook_post_handlers() // zend_hash_destroy(&tempht); /* And now we can overwrite the destructor for post entries */ // SG(known_post_content_types).pDestructor = (dtor_func_t)suhosin_post_handler_modification; - + /* we have to stop mbstring from replacing our post handler */ // if (zend_hash_find(EG(ini_directives), "mbstring.encoding_translation", sizeof("mbstring.encoding_translation"), (void **) &ini_entry) == FAILURE) { // return; @@ -122,10 +119,10 @@ void suhosin_hook_post_handlers() // void suhosin_unhook_post_handlers() // { // zend_ini_entry *ini_entry; -// +// // /* Restore to an empty destructor */ // SG(known_post_content_types).pDestructor = NULL; -// +// // /* Now restore the ini entry handler */ // if (zend_hash_find(EG(ini_directives), "mbstring.encoding_translation", sizeof("mbstring.encoding_translation"), (void **) &ini_entry) == FAILURE) { // return; diff --git a/rfc1867.c b/rfc1867.c index 983f9b4..579c235 100644 --- a/rfc1867.c +++ b/rfc1867.c @@ -25,8 +25,6 @@ */ -/* $Id$ */ - /* * This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/). diff --git a/session.c b/session.c index ad114d4..2abe2ec 100644 --- a/session.c +++ b/session.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: session.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -59,8 +56,8 @@ static void suhosin_send_cookie() int * session_send_cookie = &SESSION_G(send_cookie); char * base; zend_ini_entry *ini_entry; - - /* The following is requires to be 100% compatible to PHP + + /* The following is requires to be 100% compatible to PHP versions where the hash extension is not available by default */ if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), ZEND_STRL("session.hash_bits_per_character"))) != NULL) { #ifndef ZTS @@ -81,12 +78,12 @@ static int (*old_SessionRINIT)(INIT_FUNC_ARGS) = NULL; static int suhosin_hook_s_read(PS_READ_ARGS) { zend_string *new_key = key; - + /* protect session vars */ /* if (SESSION_G(http_session_vars) && SESSION_G(http_session_vars)->type == IS_ARRAY) { SESSION_G(http_session_vars)->refcount++; }*/ - + /* protect dumb session handlers */ if (COND_DUMB_SH) { regenerate: @@ -105,10 +102,10 @@ regenerate: if (r == SUCCESS && SUHOSIN7_G(session_encrypt) && val != NULL && *val != NULL && ZSTR_LEN(*val)) { char cryptkey[33]; - + // SUHOSIN7_G(do_not_scan) = 1; S7_GENERATE_KEY(session, cryptkey); - + zend_string *orig_val = *val; *val = suhosin_decrypt_string(ZSTR_VAL(*val), ZSTR_LEN(*val), "", 0, (char *)cryptkey, SUHOSIN7_G(session_checkraddr)); // SUHOSIN7_G(do_not_scan) = 0; @@ -117,7 +114,7 @@ regenerate: } zend_string_release(orig_val); } - + return r; } @@ -132,7 +129,7 @@ static int suhosin_hook_s_write(PS_WRITE_ARGS) char cryptkey[33]; // SUHOSIN7_G(do_not_scan) = 1; S7_GENERATE_KEY(session, cryptkey); - + zend_string *v = suhosin_encrypt_string(ZSTR_VAL(val), ZSTR_LEN(val), "", 0, cryptkey); // SUHOSIN7_G(do_not_scan) = 0; @@ -140,7 +137,7 @@ static int suhosin_hook_s_write(PS_WRITE_ARGS) } return SUHOSIN7_G(old_s_write)(mod_data, key, val, maxlifetime); - + // return_write: /* protect session vars */ /* if (SESSION_G(http_session_vars) && SESSION_G(http_session_vars)->type == IS_ARRAY) { @@ -163,7 +160,7 @@ static int suhosin_hook_s_destroy(PS_DESTROY_ARGS) if (COND_DUMB_SH) { return FAILURE; } - + return SUHOSIN7_G(old_s_destroy)(mod_data, key); } @@ -171,7 +168,7 @@ static void suhosin_hook_session_module() { ps_module *old_mod = SESSION_G(mod); ps_module *mod; - + if (old_mod == NULL || SUHOSIN7_G(s_module) == old_mod) { return; } @@ -182,19 +179,19 @@ static void suhosin_hook_session_module() return; } } - + SUHOSIN7_G(s_original_mod) = old_mod; - + mod = SUHOSIN7_G(s_module); memcpy(mod, old_mod, sizeof(ps_module)); - + SUHOSIN7_G(old_s_read) = mod->s_read; mod->s_read = suhosin_hook_s_read; SUHOSIN7_G(old_s_write) = mod->s_write; mod->s_write = suhosin_hook_s_write; SUHOSIN7_G(old_s_destroy) = mod->s_destroy; mod->s_destroy = suhosin_hook_s_destroy; - + SESSION_G(mod) = mod; } @@ -211,7 +208,7 @@ static PHP_INI_MH(suhosin_OnUpdateSaveHandler) SESSION_G(mod) = SUHOSIN7_G(s_original_mod); int r = old_OnUpdateSaveHandler(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); - + suhosin_hook_session_module(); return r; @@ -234,7 +231,7 @@ static int suhosin_hook_session_RINIT(INIT_FUNC_ARGS) void suhosin_hook_session() { zend_module_entry *module; - + if ((module = zend_hash_str_find_ptr(&module_registry, ZEND_STRL("session"))) == NULL) { return; } @@ -248,15 +245,15 @@ void suhosin_hook_session() session_globals = module->globals_ptr; } #endif - + if (old_OnUpdateSaveHandler != NULL) { return; } - + /* hook request startup function of session module */ old_SessionRINIT = module->request_startup_func; module->request_startup_func = suhosin_hook_session_RINIT; - + /* retrieve pointer to session.save_handler ini entry */ zend_ini_entry *ini_entry; if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), ZEND_STRL("session.save_handler"))) != NULL) { @@ -282,14 +279,14 @@ void suhosin_hook_session() // if (old_OnUpdateSaveHandler == NULL) { // return; // } -// +// // /* retrieve pointer to session.save_handler ini entry */ // zend_ini_entry *ini_entry; // if ((ini_entry = zend_hash_find(EG(ini_directives), ZEND_STRL("session.save_handler"))) == NULL) { // return; // } // ini_entry->on_modify = old_OnUpdateSaveHandler; -// old_OnUpdateSaveHandler = NULL; +// old_OnUpdateSaveHandler = NULL; // } #else /* HAVE_PHP_SESSION */ diff --git a/sha256.c b/sha256.c index ae9f0da..264bb8e 100644 --- a/sha256.c +++ b/sha256.c @@ -17,12 +17,10 @@ +----------------------------------------------------------------------+ */ -/* $Id: sha256.c $ */ - #include #include "php.h" -/* This code is heavily based on the PHP md5/sha1 implementations */ +/* This code is heavily based on the PHP md5/sha1 implementations */ #include "sha256.h" @@ -48,7 +46,7 @@ static PHP_FUNCTION(suhosin_sha256) char sha256str[65]; suhosin_SHA256_CTX context; unsigned char digest[32]; - + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &arg, &arg_len, &raw_output) == FAILURE) { return; } @@ -141,7 +139,7 @@ static unsigned char PADDING[64] = */ #define W(i) ( tmp1=ROTATE_RIGHT(x[(i-15)&15],7)^ROTATE_RIGHT(x[(i-15)&15],18)^(x[(i-15)&15] >> 3), \ tmp2=ROTATE_RIGHT(x[(i-2)&15],17)^ROTATE_RIGHT(x[(i-2)&15],19)^(x[(i-2)&15] >> 10), \ - (x[i&15]=x[i&15] + tmp1 + x[(i-7)&15] + tmp2) ) + (x[i&15]=x[i&15] + tmp1 + x[(i-7)&15] + tmp2) ) /* ROUND function of sha256 */ @@ -150,8 +148,8 @@ static unsigned char PADDING[64] = t1 = (h) + H((e)) + I((e), (f), (g)) + (k) + (php_uint32)(w); \ (h) = F((a)) + G((a), (b), (c)) + t1; \ (d) += t1; \ - } - + } + /* {{{ suhosin_SHA256Init * SHA256 initialization. Begins an SHA256 operation, writing a new context. @@ -168,7 +166,7 @@ void suhosin_SHA256Init(suhosin_SHA256_CTX * context) context->state[4] = 0x510e527f; context->state[5] = 0x9b05688c; context->state[6] = 0x1f83d9ab; - context->state[7] = 0x5be0cd19; + context->state[7] = 0x5be0cd19; } /* }}} */ @@ -232,7 +230,7 @@ void suhosin_SHA256Final(unsigned char digest[32], suhosin_SHA256_CTX * context) bits[2] = (context->count[1] >> 8) & 0xFF; bits[1] = (context->count[1] >> 16) & 0xFF; bits[0] = (context->count[1] >> 24) & 0xFF; - + /* Pad out to 56 mod 64. */ index = (unsigned int) ((context->count[0] >> 3) & 0x3f); @@ -397,7 +395,7 @@ void suhosin_hook_sha256() if (zend_hash_str_find(CG(function_table), ZEND_STRL("sha256"))) { return; } - + /* add the sha256 functions */ zend_register_functions(NULL, suhosin_sha256_functions, NULL, MODULE_PERSISTENT); } diff --git a/sha256.h b/sha256.h index d728506..03b10b7 100644 --- a/sha256.h +++ b/sha256.h @@ -17,8 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: sha256.h $ */ - #ifndef SHA256_H #define SHA256_H diff --git a/suhosin7.c b/suhosin7.c index 2952629..2ec5b68 100644 --- a/suhosin7.c +++ b/suhosin7.c @@ -18,8 +18,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -40,7 +38,7 @@ ZEND_DECLARE_MODULE_GLOBALS(suhosin7) #define PERDIR_CHECK(lower) \ if (!SUHOSIN7_G(lower ## _perdir) && stage == ZEND_INI_STAGE_HTACCESS) { \ return FAILURE; \ - } + } #define LOG_PERDIR_CHECK() PERDIR_CHECK(log) #define EXEC_PERDIR_CHECK() PERDIR_CHECK(exec) @@ -98,9 +96,9 @@ static ZEND_INI_MH(OnUpdateSuhosin_perdir) if (new_value == NULL || ZSTR_LEN(new_value) == 0) { return SUCCESS; } - + char *tmp = ZSTR_VAL(new_value); - + /* should we deactivate perdir completely? */ if (*tmp == '0') { return SUCCESS; @@ -145,7 +143,7 @@ list_destroy: *ht = pemalloc(sizeof(HashTable), 1); zend_hash_init(*ht, 5, NULL, NULL, 1); - + char *val = estrndup(list, strlen(list)); if (lc) { zend_str_tolower(val, strlen(list)); @@ -153,7 +151,7 @@ list_destroy: char *e = val; char *s = NULL; - + while (*e) { switch (*e) { case ' ': @@ -299,25 +297,25 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("suhosin.executor.func.blacklist", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_func_blacklist) // STD_S7_INI_BOOLEAN("suhosin.executor.disable_eval", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecBool, executor_disable_eval) STD_S7_INI_BOOLEAN("suhosin.executor.disable_emodifier", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecBool, executor_disable_emod) - // + // STD_S7_INI_BOOLEAN("suhosin.executor.allow_symlink", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecBool, executor_allow_symlink) STD_S7_INI_ENTRY("suhosin.executor.max_depth", "750", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecLong, max_execution_depth) - // - // + // + // STD_S7_INI_BOOLEAN("suhosin.multiheader", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateMiscBool, allow_multiheader) // STD_S7_INI_ENTRY("suhosin.mail.protect", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateMiscLong, mailprotect) STD_S7_INI_ENTRY("suhosin.memory_limit", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateMiscLong, memory_limit) STD_S7_INI_BOOLEAN("suhosin.simulation", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateMiscBool, simulation) // STD_S7_INI_ENTRY("suhosin.filter.action", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscString, filter_action) - // + // STD_S7_INI_BOOLEAN("suhosin.protectkey", "1", PHP_INI_SYSTEM, OnUpdateBool, protectkey) STD_S7_INI_BOOLEAN("suhosin.coredump", "0", PHP_INI_SYSTEM, OnUpdateBool, coredump) // STD_S7_INI_BOOLEAN("suhosin.stealth", "1", PHP_INI_SYSTEM, OnUpdateBool, stealth) // STD_S7_INI_BOOLEAN("suhosin.apc_bug_workaround", "0", PHP_INI_SYSTEM, OnUpdateBool, apc_bug_workaround) STD_S7_INI_BOOLEAN("suhosin.disable.display_errors", "0", PHP_INI_SYSTEM, OnUpdate_disable_display_errors, disable_display_errors) - - - // + + + // STD_S7_INI_ENTRY("suhosin.request.max_vars", "1000", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestLong, max_request_variables) STD_S7_INI_ENTRY("suhosin.request.max_varname_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestLong, max_varname_length) STD_S7_INI_ENTRY("suhosin.request.max_value_length", "1000000", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestLong, max_value_length) @@ -328,7 +326,7 @@ PHP_INI_BEGIN() STD_S7_INI_ENTRY("suhosin.request.array_index_char_blacklist", "'\"+<>;()", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestString, array_index_blacklist) STD_S7_INI_ENTRY("suhosin.request.disallow_nul", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestBool, disallow_nul) STD_S7_INI_ENTRY("suhosin.request.disallow_ws", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateRequestBool, disallow_ws) - // + // STD_S7_INI_ENTRY("suhosin.cookie.max_vars", "100", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieLong, max_cookie_vars) STD_S7_INI_ENTRY("suhosin.cookie.max_name_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieLong, max_cookie_name_length) STD_S7_INI_ENTRY("suhosin.cookie.max_totalname_length", "256", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieLong, max_cookie_totalname_length) @@ -337,7 +335,7 @@ PHP_INI_BEGIN() STD_S7_INI_ENTRY("suhosin.cookie.max_array_index_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieLong, max_cookie_array_index_length) STD_S7_INI_ENTRY("suhosin.cookie.disallow_nul", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieBool, disallow_cookie_nul) STD_S7_INI_ENTRY("suhosin.cookie.disallow_ws", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateCookieBool, disallow_cookie_ws) - // + // STD_S7_INI_ENTRY("suhosin.get.max_vars", "100", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetLong, max_get_vars) STD_S7_INI_ENTRY("suhosin.get.max_name_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetLong, max_get_name_length) STD_S7_INI_ENTRY("suhosin.get.max_totalname_length", "256", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetLong, max_get_totalname_length) @@ -346,7 +344,7 @@ PHP_INI_BEGIN() STD_S7_INI_ENTRY("suhosin.get.max_array_index_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetLong, max_get_array_index_length) STD_S7_INI_ENTRY("suhosin.get.disallow_nul", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetBool, disallow_get_nul) STD_S7_INI_ENTRY("suhosin.get.disallow_ws", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateGetBool, disallow_get_ws) - // + // STD_S7_INI_ENTRY("suhosin.post.max_vars", "1000", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostLong, max_post_vars) STD_S7_INI_ENTRY("suhosin.post.max_name_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostLong, max_post_name_length) STD_S7_INI_ENTRY("suhosin.post.max_totalname_length", "256", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostLong, max_post_totalname_length) @@ -355,7 +353,7 @@ PHP_INI_BEGIN() STD_S7_INI_ENTRY("suhosin.post.max_array_index_length", "64", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostLong, max_post_array_index_length) STD_S7_INI_ENTRY("suhosin.post.disallow_nul", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostBool, disallow_post_nul) STD_S7_INI_ENTRY("suhosin.post.disallow_ws", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdatePostBool, disallow_post_ws) - // + // STD_S7_INI_ENTRY("suhosin.upload.max_uploads", "25", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateUploadLong, upload_limit) STD_S7_INI_ENTRY("suhosin.upload.max_newlines", "100", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateUploadLong, upload_max_newlines) STD_S7_INI_ENTRY("suhosin.upload.disallow_elf", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateUploadBool, upload_disallow_elf) @@ -403,7 +401,7 @@ PHP_INI_BEGIN() // STD_S7_INI_BOOLEAN("suhosin.server.encode", "1", PHP_INI_SYSTEM, OnUpdateBool, server_encode) STD_S7_INI_BOOLEAN("suhosin.server.strip", "1", PHP_INI_SYSTEM, OnUpdateBool, server_strip) - // + // STD_S7_INI_ENTRY("suhosin.rand.seedingkey", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscString, seedingkey) STD_S7_INI_BOOLEAN("suhosin.rand.reseed_every_request", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, reseed_every_request) STD_S7_INI_BOOLEAN("suhosin.srand.ignore", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, srand_ignore) @@ -428,7 +426,7 @@ char *suhosin_getenv(char *name, size_t name_len) } else { /* fallback to the system's getenv() function */ char *tmp; - + name = estrndup(name, name_len); tmp = getenv(name); efree(name); @@ -476,7 +474,7 @@ PHP_MINIT_FUNCTION(suhosin7) REGISTER_MAIN_LONG_CONSTANT("S_ALL", S_ALL, CONST_PERSISTENT | CONST_CS); REGISTER_INI_ENTRIES(); - + #if !defined(HAVE_PHP_SESSION) && !defined(SUHOSIN_NO_SESSION_WARNING) php_error_docref(NULL, E_WARNING, "Suhosin was compiled without session support, which is probably not what you want. All session related features will not be available, e.g. session encryption. If session support is really not needed, recompile Suhosin with -DSUHOSIN_NO_SESSION_WARNING=1 to suppress this warning."); #endif @@ -492,7 +490,7 @@ PHP_MINIT_FUNCTION(suhosin7) if (i->on_modify) { i->on_modify(i, val0, i->mh_arg1, i->mh_arg2, i->mh_arg3, ZEND_INI_STAGE_STARTUP); } - + SDEBUG("display_errors=%s", ZSTR_VAL(val0)); if (SUHOSIN7_G(disable_display_errors) >= 2) { i->modified = 0; @@ -565,9 +563,9 @@ PHP_RINIT_FUNCTION(suhosin7) PHP_RSHUTDOWN_FUNCTION(suhosin7) { SDEBUG("(RSHUTDOWN)"); - /* We need to clear the input filtering + /* We need to clear the input filtering variables in the request shutdown - because input filtering is done before + because input filtering is done before RINIT */ SUHOSIN7_G(cur_request_variables) = 0; @@ -621,7 +619,7 @@ PHP_MINFO_FUNCTION(suhosin7) php_info_print_box_start(0); if (!sapi_module.phpinfo_as_text) { zend_string *enc_logo; - + PUTS("displayer = NULL; } diff --git a/suhosin_rfc1867.h b/suhosin_rfc1867.h index 5d946b0..52878b8 100644 --- a/suhosin_rfc1867.h +++ b/suhosin_rfc1867.h @@ -17,8 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: suhosin_rfc1867.h,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ */ - #ifndef SUHOSIN_RFC1867_H #define SUHOSIN_RFC1867_H @@ -37,11 +35,11 @@ // #define MULTIPART_EVENT_FILE_DATA 3 // #define MULTIPART_EVENT_FILE_END 4 // #define MULTIPART_EVENT_END 5 -// +// // typedef struct _multipart_event_start { // size_t content_length; // } multipart_event_start; -// +// // typedef struct _multipart_event_formdata { // size_t post_bytes_processed; // char *name; @@ -49,13 +47,13 @@ // size_t length; // size_t *newlength; // } multipart_event_formdata; -// +// // typedef struct _multipart_event_file_start { // size_t post_bytes_processed; // char *name; // char **filename; // } multipart_event_file_start; -// +// // typedef struct _multipart_event_file_data { // size_t post_bytes_processed; // zend_off_t offset; @@ -63,20 +61,20 @@ // size_t length; // size_t *newlength; // } multipart_event_file_data; -// +// // typedef struct _multipart_event_file_end { // size_t post_bytes_processed; // char *temp_filename; // int cancel_upload; // } multipart_event_file_end; -// +// // typedef struct _multipart_event_end { // size_t post_bytes_processed; // } multipart_event_end; -// -// +// +// // #endif -// +// int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra); SAPI_POST_HANDLER_FUNC(suhosin_rfc1867_post_handler); diff --git a/treat_data.c b/treat_data.c index bdd06c0..25c24c4 100644 --- a/treat_data.c +++ b/treat_data.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: treat_data.c $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -38,19 +35,19 @@ SAPI_TREAT_DATA_FUNC(suhosin_treat_data) { switch (arg) { case PARSE_POST: - if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_post_vars) == 0 || + if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_post_vars) == 0 || SUHOSIN7_G(max_request_variables) <= SUHOSIN7_G(max_post_vars))) { SUHOSIN7_G(max_post_vars) = SUHOSIN7_G(max_request_variables); } break; case PARSE_GET: - if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_get_vars) == 0 || + if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_get_vars) == 0 || SUHOSIN7_G(max_request_variables) <= SUHOSIN7_G(max_get_vars))) { SUHOSIN7_G(max_get_vars) = SUHOSIN7_G(max_request_variables); } break; case PARSE_COOKIE: - if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_cookie_vars) == 0 || + if (SUHOSIN7_G(max_request_variables) && (SUHOSIN7_G(max_cookie_vars) == 0 || SUHOSIN7_G(max_request_variables) <= SUHOSIN7_G(max_cookie_vars))) { SUHOSIN7_G(max_cookie_vars) = SUHOSIN7_G(max_request_variables); } @@ -60,7 +57,7 @@ SAPI_TREAT_DATA_FUNC(suhosin_treat_data) if (arg == PARSE_COOKIE && SUHOSIN7_G(cookie_encrypt) && SG(request_info).cookie_data) { SG(request_info).cookie_data = suhosin_cookie_decryptor(SG(request_info).cookie_data); } - + if (orig_treat_data) { orig_treat_data(arg, str, destArray); } diff --git a/ufilter.c b/ufilter.c index b7543ea..af4a051 100644 --- a/ufilter.c +++ b/ufilter.c @@ -17,9 +17,6 @@ | Ben Fuhrmannek | +----------------------------------------------------------------------+ */ -/* - $Id: ufilter.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ -*/ #ifdef HAVE_CONFIG_H #include "config.h" -- cgit v1.3