summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fuhrmannek2014-09-22 17:36:21 +0200
committerBen Fuhrmannek2014-09-22 17:36:21 +0200
commitc3f4330efb42214b1a23d756001f140c5968e1a7 (patch)
tree43f1d416d5b8e89fdb4ec4c4322aba49347595da
parent597ab68817b833547d99bd9bf7cd47d728e24fef (diff)
warn if ini contstants are not available
-rw-r--r--suhosin.c31
-rw-r--r--suhosin.ini6
2 files changed, 30 insertions, 7 deletions
diff --git a/suhosin.c b/suhosin.c
index fc84a94..964fbf9 100644
--- a/suhosin.c
+++ b/suhosin.c
@@ -386,6 +386,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_syslog)
386 if (!new_value) { 386 if (!new_value) {
387 SUHOSIN_G(log_syslog) = (S_ALL & ~S_SQL) | S_MEMORY; 387 SUHOSIN_G(log_syslog) = (S_ALL & ~S_SQL) | S_MEMORY;
388 } else { 388 } else {
389 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
390 SUHOSIN_G(log_syslog) = (S_ALL & ~S_SQL) | S_MEMORY;
391 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.syslog=%s", new_value);
392 return FAILURE;
393 }
389 SUHOSIN_G(log_syslog) = atoi(new_value) | S_MEMORY; 394 SUHOSIN_G(log_syslog) = atoi(new_value) | S_MEMORY;
390 } 395 }
391 return SUCCESS; 396 return SUCCESS;
@@ -416,6 +421,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_sapi)
416 if (!new_value) { 421 if (!new_value) {
417 SUHOSIN_G(log_sapi) = (S_ALL & ~S_SQL); 422 SUHOSIN_G(log_sapi) = (S_ALL & ~S_SQL);
418 } else { 423 } else {
424 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
425 SUHOSIN_G(log_sapi) = (S_ALL & ~S_SQL);
426 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.sapi=%s", new_value);
427 return FAILURE;
428 }
419 SUHOSIN_G(log_sapi) = atoi(new_value); 429 SUHOSIN_G(log_sapi) = atoi(new_value);
420 } 430 }
421 return SUCCESS; 431 return SUCCESS;
@@ -426,6 +436,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_stdout)
426 if (!new_value) { 436 if (!new_value) {
427 SUHOSIN_G(log_stdout) = (S_ALL & ~S_SQL); 437 SUHOSIN_G(log_stdout) = (S_ALL & ~S_SQL);
428 } else { 438 } else {
439 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
440 SUHOSIN_G(log_stdout) = (S_ALL & ~S_SQL);
441 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.stdout=%s", new_value);
442 return FAILURE;
443 }
429 SUHOSIN_G(log_stdout) = atoi(new_value); 444 SUHOSIN_G(log_stdout) = atoi(new_value);
430 } 445 }
431 return SUCCESS; 446 return SUCCESS;
@@ -436,6 +451,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_script)
436 if (!new_value) { 451 if (!new_value) {
437 SUHOSIN_G(log_script) = S_ALL & ~S_MEMORY; 452 SUHOSIN_G(log_script) = S_ALL & ~S_MEMORY;
438 } else { 453 } else {
454 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
455 SUHOSIN_G(log_script) = S_ALL & ~S_MEMORY;
456 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.script=%s", new_value);
457 return FAILURE;
458 }
439 SUHOSIN_G(log_script) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL); 459 SUHOSIN_G(log_script) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
440 } 460 }
441 return SUCCESS; 461 return SUCCESS;
@@ -458,6 +478,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_phpscript)
458 if (!new_value) { 478 if (!new_value) {
459 SUHOSIN_G(log_phpscript) = S_ALL & ~S_MEMORY; 479 SUHOSIN_G(log_phpscript) = S_ALL & ~S_MEMORY;
460 } else { 480 } else {
481 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
482 SUHOSIN_G(log_phpscript) = S_ALL & ~S_MEMORY;
483 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.phpscript=%s", new_value);
484 return FAILURE;
485 }
461 SUHOSIN_G(log_phpscript) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL); 486 SUHOSIN_G(log_phpscript) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
462 } 487 }
463 return SUCCESS; 488 return SUCCESS;
@@ -468,6 +493,11 @@ static ZEND_INI_MH(OnUpdateSuhosin_log_file)
468 if (!new_value) { 493 if (!new_value) {
469 SUHOSIN_G(log_file) = S_ALL & ~S_MEMORY; 494 SUHOSIN_G(log_file) = S_ALL & ~S_MEMORY;
470 } else { 495 } else {
496 if (is_numeric_string(new_value, strlen(new_value), NULL, NULL, 0) != IS_LONG) {
497 SUHOSIN_G(log_file) = S_ALL & ~S_MEMORY;
498 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in suhosin.log.file=%s", new_value);
499 return FAILURE;
500 }
471 SUHOSIN_G(log_file) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL); 501 SUHOSIN_G(log_file) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
472 } 502 }
473 return SUCCESS; 503 return SUCCESS;
@@ -921,7 +951,6 @@ PHP_MINIT_FUNCTION(suhosin)
921 ZEND_INIT_MODULE_GLOBALS(suhosin, php_suhosin_init_globals, NULL); 951 ZEND_INIT_MODULE_GLOBALS(suhosin, php_suhosin_init_globals, NULL);
922 952
923 /* only register constants if they have not previously been registered by a possible patched PHP */ 953 /* only register constants if they have not previously been registered by a possible patched PHP */
924
925 if (zend_hash_exists(EG(zend_constants), "S_MEMORY", sizeof("S_MEMORY"))==0) { 954 if (zend_hash_exists(EG(zend_constants), "S_MEMORY", sizeof("S_MEMORY"))==0) {
926 REGISTER_MAIN_LONG_CONSTANT("S_MEMORY", S_MEMORY, CONST_PERSISTENT | CONST_CS); 955 REGISTER_MAIN_LONG_CONSTANT("S_MEMORY", S_MEMORY, CONST_PERSISTENT | CONST_CS);
927 REGISTER_MAIN_LONG_CONSTANT("S_VARS", S_VARS, CONST_PERSISTENT | CONST_CS); 956 REGISTER_MAIN_LONG_CONSTANT("S_VARS", S_VARS, CONST_PERSISTENT | CONST_CS);
diff --git a/suhosin.ini b/suhosin.ini
index 3ae8ff5..fc16f62 100644
--- a/suhosin.ini
+++ b/suhosin.ini
@@ -105,9 +105,6 @@
105; | LOG_LOCAL7 | 31 | 105; | LOG_LOCAL7 | 31 |
106; +--------------+-------+ 106; +--------------+-------+
107; 107;
108; Using constant names is only supported with the Suhosin-Patch. If in doubt, use
109; the numeric value.
110;
111;suhosin.log.syslog.facility = LOG_USER 108;suhosin.log.syslog.facility = LOG_USER
112; 109;
113 110
@@ -141,9 +138,6 @@
141; |LOG_ERR | 7 | 138; |LOG_ERR | 7 |
142; +------------+-------+ 139; +------------+-------+
143; 140;
144; Using constant names is only supported with the Suhosin-Patch. If in doubt, use
145; the numeric value.
146;
147;suhosin.log.syslog.priority = LOG_ALERT 141;suhosin.log.syslog.priority = LOG_ALERT
148; 142;
149 143