summaryrefslogtreecommitdiff
path: root/suhosin7.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2016-02-22 18:59:55 +0100
committerBen Fuhrmannek2016-02-22 18:59:55 +0100
commitcb4150c0b3ef77631a62850e1449465f824a0f03 (patch)
treea1ec9b49e8c48616913cdd1466b6d88d96f1d671 /suhosin7.c
parent1892d326b40a914538f1a87cf5ea4ca226f7c72f (diff)
ported disable display_errors
Diffstat (limited to 'suhosin7.c')
-rw-r--r--suhosin7.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/suhosin7.c b/suhosin7.c
index c4a89ef..bfe349f 100644
--- a/suhosin7.c
+++ b/suhosin7.c
@@ -208,8 +208,42 @@ static ZEND_INI_MH(OnUpdateSuhosin_cookie_plainlist)
208 return SUCCESS; 208 return SUCCESS;
209} 209}
210 210
211static ZEND_INI_MH(OnUpdate_disable_display_errors) /* {{{ */
212{
213 zend_bool *p, val;
214#ifndef ZTS
215 char *base = (char *) mh_arg2;
216#else
217 char *base;
218
219 base = (char *) ts_resource(*((int *) mh_arg2));
220#endif
221
222 p = (zend_bool *) (base+(size_t) mh_arg1);
223
224 if (zend_string_equals_literal_ci(new_value, "on") ||
225 zend_string_equals_literal_ci(new_value, "yes") ||
226 zend_string_equals_literal_ci(new_value, "true")) {
227 *p = (zend_bool) 1;
228 } else if (zend_string_equals_literal_ci(new_value, "fail")) {
229 *p = (zend_bool) 2;
230 }
231 else {
232 *p = (zend_bool) zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
233 }
234
235 return SUCCESS;
236}
237/* }}} */
238
239static ZEND_INI_MH(OnUpdate_fail)
240{
241 return FAILURE;
242}
243
211/* ------------------------------------------------------------------------ */ 244/* ------------------------------------------------------------------------ */
212 245
246
213#define DEF_LOG_UPDATER(fname, varname, inistr) static ZEND_INI_MH(fname) \ 247#define DEF_LOG_UPDATER(fname, varname, inistr) static ZEND_INI_MH(fname) \
214{ \ 248{ \
215 LOG_PERDIR_CHECK() \ 249 LOG_PERDIR_CHECK() \
@@ -287,7 +321,7 @@ PHP_INI_BEGIN()
287 // STD_S7_INI_BOOLEAN("suhosin.coredump", "0", PHP_INI_SYSTEM, OnUpdateBool, coredump) 321 // STD_S7_INI_BOOLEAN("suhosin.coredump", "0", PHP_INI_SYSTEM, OnUpdateBool, coredump)
288 // STD_S7_INI_BOOLEAN("suhosin.stealth", "1", PHP_INI_SYSTEM, OnUpdateBool, stealth) 322 // STD_S7_INI_BOOLEAN("suhosin.stealth", "1", PHP_INI_SYSTEM, OnUpdateBool, stealth)
289 // STD_S7_INI_BOOLEAN("suhosin.apc_bug_workaround", "0", PHP_INI_SYSTEM, OnUpdateBool, apc_bug_workaround) 323 // STD_S7_INI_BOOLEAN("suhosin.apc_bug_workaround", "0", PHP_INI_SYSTEM, OnUpdateBool, apc_bug_workaround)
290 // STD_S7_INI_BOOLEAN("suhosin.disable.display_errors", "0", PHP_INI_SYSTEM, OnUpdate_disable_display_errors, disable_display_errors) 324 STD_S7_INI_BOOLEAN("suhosin.disable.display_errors", "0", PHP_INI_SYSTEM, OnUpdate_disable_display_errors, disable_display_errors)
291 325
292 326
293 // 327 //
@@ -450,7 +484,34 @@ PHP_MINIT_FUNCTION(suhosin7)
450#endif 484#endif
451 485
452 // TODO: stealth loading 486 // TODO: stealth loading
453 487
488 /* Force display_errors=off */
489 if (SUHOSIN7_G(disable_display_errors)) {
490 zend_ini_entry *i;
491 zend_string *ini_name = zend_string_init(ZEND_STRL("display_errors"), 0);
492 zend_string *val0 = zend_string_init(ZEND_STRL("0"), 1);
493 if ((i = zend_hash_find_ptr(EG(ini_directives), ini_name))) {
494 if (i->on_modify) {
495 i->on_modify(i, val0, i->mh_arg1, i->mh_arg2, i->mh_arg3, ZEND_INI_STAGE_STARTUP);
496 // i->on_modify = NULL;
497 }
498
499 SDEBUG("display_errors=%s", ZSTR_VAL(val0));
500 if (SUHOSIN7_G(disable_display_errors) >= 2) {
501 i->modified = 0;
502 i->value = zend_string_copy(val0);
503 i->on_modify = OnUpdate_fail;
504 } else {
505 i->on_modify = NULL;
506 }
507 } else {
508 // no display_errors?
509 suhosin_log(S_INTERNAL, "suhosin cannot protect display_errors: option not found");
510 }
511 zend_string_release(ini_name);
512 zend_string_release(val0);
513 }
514
454 // hooks 515 // hooks
455 // suhosin_hook_memory_limit(); 516 // suhosin_hook_memory_limit();
456 suhosin_hook_treat_data(); 517 suhosin_hook_treat_data();