forked from sektioneins/suhosin7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreat_data.c
82 lines (73 loc) · 2.83 KB
/
treat_data.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2016 SektionEins GmbH |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Stefan Esser <[email protected]> |
| Ben Fuhrmannek <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_suhosin7.h"
#include "SAPI.h"
#include "php_variables.h"
#include "ext/standard/url.h"
static SAPI_TREAT_DATA_FUNC((*orig_treat_data)) = NULL;
SAPI_TREAT_DATA_FUNC(suhosin_treat_data)
{
switch (arg) {
case PARSE_POST:
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 ||
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 ||
SUHOSIN7_G(max_request_variables) <= SUHOSIN7_G(max_cookie_vars))) {
SUHOSIN7_G(max_cookie_vars) = SUHOSIN7_G(max_request_variables);
}
break;
}
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);
}
}
void suhosin_hook_treat_data()
{
if (orig_treat_data == NULL) {
orig_treat_data = sapi_module.treat_data;
}
sapi_module.treat_data = suhosin_treat_data;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/