Showing preview only (609K chars total). Download the full file or copy to clipboard to get everything.
Repository: stefanesser/suhosin
Branch: master
Commit: 611d261ea69d
Files: 246
Total size: 550.3 KB
Directory structure:
gitextract_i6z6y2bt/
├── .gitignore
├── .travis.yml
├── CREDITS
├── Changelog
├── LICENSE
├── README.md
├── aes.c
├── config.m4
├── config.w32
├── crypt.c
├── ex_imp.c
├── execute.c
├── header.c
├── ifilter.c
├── log.c
├── mbregex/
│ ├── COPYING.LIB
│ └── mbregex.h
├── mbregex.h
├── memory_limit.c
├── php_suhosin.h
├── pkg/
│ └── build_deb.sh
├── pledge.c
├── pledge.h
├── post_handler.c
├── rfc1867_new.c
├── session.c
├── sha256.c
├── sha256.h
├── suhosin.c
├── suhosin.ini
├── suhosin_logo.h
├── suhosin_rfc1867.h
├── tests/
│ ├── cookie/
│ │ ├── crypt.checkraddr_4.phpt
│ │ ├── crypt.checkraddr_4_incorrect.phpt
│ │ ├── crypt.cryptlist.phpt
│ │ ├── crypt.docroot.phpt
│ │ ├── crypt.invalid.phpt
│ │ ├── crypt.key_default.phpt
│ │ ├── crypt.key_empty.phpt
│ │ ├── crypt.key_empty_remote_addr.phpt
│ │ ├── crypt.no_encryption.phpt
│ │ ├── crypt.plainlist.phpt
│ │ ├── crypt.raddr_1.phpt
│ │ ├── crypt.raddr_2.phpt
│ │ ├── crypt.raddr_3.phpt
│ │ ├── crypt.raddr_4.phpt
│ │ └── crypt.ua.phpt
│ ├── empty.inc
│ ├── executor/
│ │ ├── allow_symlink_off.phpt
│ │ ├── allow_symlink_on.phpt
│ │ ├── disable_emod_off.phpt
│ │ ├── disable_emod_on.phpt
│ │ ├── disable_eval_off.phpt
│ │ ├── disable_eval_on.phpt
│ │ ├── eval_blacklist.phpt
│ │ ├── eval_blacklist_printf.phpt
│ │ ├── eval_blacklist_printf_function_exists.phpt
│ │ ├── eval_whitelist_absmax.phpt
│ │ ├── eval_whitelist_call_user_func.phpt
│ │ ├── function_blacklist.phpt
│ │ ├── function_blacklist_printf.phpt
│ │ ├── function_blacklist_printf_function_exists.phpt
│ │ ├── function_call_user_func.phpt
│ │ ├── function_whitelist.phpt
│ │ ├── function_whitelist_absmax.phpt
│ │ ├── function_whitelist_call_user_func.phpt
│ │ ├── function_whitelist_function_exists.phpt
│ │ ├── function_whitelist_maxabs.phpt
│ │ ├── function_whitelist_without_function_exists.phpt
│ │ ├── memory_limit.phpt
│ │ ├── memory_limit_64bit.phpt
│ │ ├── memory_limit_64bit_10G.phpt
│ │ ├── memory_limit_negative.phpt
│ │ ├── memory_limit_other_hardlimit.phpt
│ │ ├── preg_replace.phpt
│ │ ├── preg_replace_error.phpt
│ │ ├── recursion_maxdepth.phpt
│ │ └── user_session_handler.phpt
│ ├── filter/
│ │ ├── cookie_disallow_nul.phpt
│ │ ├── cookie_disallow_ws.phpt
│ │ ├── cookie_max_array_depth.phpt
│ │ ├── cookie_max_array_index_length.phpt
│ │ ├── cookie_max_name_length.phpt
│ │ ├── cookie_max_totalname_length.phpt
│ │ ├── cookie_max_value_length.phpt
│ │ ├── cookie_max_vars.phpt
│ │ ├── filter_action_302.phpt
│ │ ├── filter_action_php.phpt
│ │ ├── filter_logging_statistics.phpt
│ │ ├── get_allow_ws.phpt
│ │ ├── get_disallow_nul.phpt
│ │ ├── get_disallow_ws.phpt
│ │ ├── get_filter_1.phpt
│ │ ├── get_filter_2.phpt
│ │ ├── get_globals.phpt
│ │ ├── get_max_array_depth.phpt
│ │ ├── get_max_array_index_length.phpt
│ │ ├── get_max_name_length.phpt
│ │ ├── get_max_totalname_length.phpt
│ │ ├── get_max_value_length.phpt
│ │ ├── input_filter_allow_nul.phpt
│ │ ├── input_filter_request_max_value_length.phpt
│ │ ├── post_disallow_nul.phpt
│ │ ├── post_disallow_nul_rfc1867.phpt
│ │ ├── post_disallow_ws.phpt
│ │ ├── post_fileupload_array_index_blacklist.phpt
│ │ ├── post_fileupload_array_index_whitelist.phpt
│ │ ├── post_fileupload_filter_1.phpt
│ │ ├── post_fileupload_filter_2.phpt
│ │ ├── post_filter_1.phpt
│ │ ├── post_filter_2.phpt
│ │ ├── post_filter_empty_avar.phpt
│ │ ├── post_filter_empty_var.phpt
│ │ ├── post_max_array_depth.phpt
│ │ ├── post_max_array_depth_rfc1867.phpt
│ │ ├── post_max_array_index_length.phpt
│ │ ├── post_max_array_index_length_rfc1867.phpt
│ │ ├── post_max_name_length.phpt
│ │ ├── post_max_name_length_rfc1867.phpt
│ │ ├── post_max_totalname_length.phpt
│ │ ├── post_max_totalname_length_rfc1867.phpt
│ │ ├── post_max_value_length.phpt
│ │ ├── post_max_value_length_rfc1867.phpt
│ │ ├── request_array_index_blacklist.phpt
│ │ ├── request_array_index_whitelist.phpt
│ │ ├── request_disallow_nul.phpt
│ │ ├── request_disallow_ws.phpt
│ │ ├── request_max_array_depth.phpt
│ │ ├── request_max_array_index_length.phpt
│ │ ├── request_max_name_length.phpt
│ │ ├── request_max_totalname_length.phpt
│ │ ├── server_encode_off.phpt
│ │ ├── server_encode_on.phpt
│ │ ├── server_filter.phpt
│ │ ├── server_strip_off.phpt
│ │ ├── server_strip_on.phpt
│ │ ├── server_user_agent_strip_off.phpt
│ │ ├── server_user_agent_strip_on.phpt
│ │ ├── suhosin_upload_disallow_binary_off.phpt
│ │ ├── suhosin_upload_disallow_binary_on.phpt
│ │ ├── suhosin_upload_disallow_binary_utf8.phpt
│ │ ├── suhosin_upload_disallow_binary_utf8fail.phpt
│ │ ├── suhosin_upload_disallow_elf.phpt
│ │ ├── suhosin_upload_disallow_elf_off.phpt
│ │ ├── suhosin_upload_max_uploads.phpt
│ │ ├── suhosin_upload_remove_binary.phpt
│ │ ├── suhosin_upload_remove_binary_utf8.phpt
│ │ └── suhosin_upload_remove_binary_utf8fail.phpt
│ ├── funcs/
│ │ ├── crypt_blowfish.phpt
│ │ ├── crypt_ext_des.phpt
│ │ ├── crypt_md5.phpt
│ │ ├── crypt_std_des.phpt
│ │ └── sha256.phpt
│ ├── include/
│ │ ├── include_allow_writable_files_off.phpt
│ │ ├── include_allow_writable_files_on.phpt
│ │ ├── include_blacklist.phpt
│ │ ├── include_blackwhitelist_empty.phpt
│ │ ├── include_constant.phpt
│ │ ├── include_etc_passwd.phpt
│ │ ├── include_max_traversal.phpt
│ │ ├── include_nul_in_filename.phpt
│ │ ├── include_once_constant.phpt
│ │ ├── include_once_tmpvar.phpt
│ │ ├── include_once_var.phpt
│ │ ├── include_tmpvar.phpt
│ │ ├── include_too_long.phpt
│ │ ├── include_uploaded_file_diff_filename.phpt
│ │ ├── include_uploaded_file_from_FILES.phpt
│ │ ├── include_var.phpt
│ │ ├── include_whitelist.phpt
│ │ ├── require_constant.phpt
│ │ ├── require_once_constant.phpt
│ │ ├── require_once_tmpvar.phpt
│ │ ├── require_once_var.phpt
│ │ ├── require_tmpvar.phpt
│ │ └── require_var.phpt
│ ├── logging/
│ │ ├── log_max_error_length.phpt
│ │ ├── logscript_executable.phpt
│ │ ├── logscript_nonexecutable.phpt
│ │ ├── logscript_nonexistant.phpt
│ │ ├── use_x_forwarded_for_off.phpt
│ │ ├── use_x_forwarded_for_off_no_remote_addr.phpt
│ │ ├── use_x_forwarded_for_on.phpt
│ │ └── use_x_forwarded_for_on_no_x_forwarded.phpt
│ ├── misc/
│ │ ├── disable_display_errors_fail.phpt
│ │ ├── disable_display_errors_off.phpt
│ │ ├── disable_display_errors_on.phpt
│ │ ├── mailprotect_1_header_nl.phpt
│ │ ├── mailprotect_1_header_nlnl.phpt
│ │ ├── mailprotect_1_subject.phpt
│ │ ├── mailprotect_1_subject_long.phpt
│ │ ├── mailprotect_1_to.phpt
│ │ ├── mailprotect_1_to_long.phpt
│ │ ├── mailprotect_2_bcc.phpt
│ │ ├── mailprotect_2_cc.phpt
│ │ ├── mailprotect_2_to.phpt
│ │ ├── mt_srand_ignore_off.phpt
│ │ ├── mt_srand_ignore_on.phpt
│ │ ├── protectkey_off.phpt
│ │ ├── protectkey_on.phpt
│ │ ├── srand_ignore_off.phpt
│ │ └── srand_ignore_on.phpt
│ ├── session/
│ │ ├── PHPSESSID_max_id_length_ok.phpt
│ │ ├── PHPSESSID_max_id_length_toolong.phpt
│ │ ├── crypt.checkraddr_4.phpt
│ │ ├── crypt.checkraddr_4_incorrect.phpt
│ │ ├── crypt.docroot.phpt
│ │ ├── crypt.key_default.phpt
│ │ ├── crypt.key_empty.phpt
│ │ ├── crypt.key_empty_remote_addr.phpt
│ │ ├── crypt.no_encryption.phpt
│ │ ├── crypt.raddr_1.phpt
│ │ ├── crypt.raddr_2.phpt
│ │ ├── crypt.raddr_3.phpt
│ │ ├── crypt.raddr_4.phpt
│ │ ├── crypt.ua.phpt
│ │ ├── max_id_length_ok.phpt
│ │ ├── max_id_length_toolong.phpt
│ │ ├── session_recursive_crash.phpt
│ │ ├── session_recursive_crash2.phpt
│ │ └── sessionhandler.inc
│ ├── skipif.inc
│ ├── skipifcli.inc
│ ├── skipifnotcli.inc
│ └── sql/
│ ├── connect.inc
│ ├── mysqli_comment_conditional.phpt
│ ├── mysqli_comment_cstyle_fail.phpt
│ ├── mysqli_comment_hashstyle_fail.phpt
│ ├── mysqli_comment_sqlstyle.phpt
│ ├── mysqli_comment_sqlstyle_fail.phpt
│ ├── mysqli_connect_invalid_username.phpt
│ ├── mysqli_multiselect.phpt
│ ├── mysqli_multiselect_fail.phpt
│ ├── mysqli_multiselect_subselect.phpt
│ ├── mysqli_no_constraints.phpt
│ ├── mysqli_open_comment.phpt
│ ├── mysqli_open_comment_fail.phpt
│ ├── mysqli_union.phpt
│ ├── mysqli_union_fail.phpt
│ ├── mysqli_user_match_error.phpt
│ ├── mysqli_user_match_ok.phpt
│ ├── mysqli_user_postfix.phpt
│ ├── mysqli_user_prefix.phpt
│ └── skipifmysqli.inc
├── treat_data.c
└── ufilter.c
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.DS_Store
/config.log
/config.guess
/config.h
/config.h.in
/config.h.in~
/config.nice
/config.status
/config.sub
/*.lo
/.deps
/.libs/
/Makefile
/Makefile.*
/ac*.m4
/autom4te.cache/
/build/
/configure
/configure.in
/install-sh
/libtool
/ltmain.sh
/missing
/mkinstalldirs
/modules/
/run-tests.php
/suhosin.la
/tests/*/*.tmp
================================================
FILE: .travis.yml
================================================
language: php
os: linux
php:
- 5.6
- 5.5
- 5.4
env:
- CC=gcc CFLAGS=""
- CC=clang CFLAGS=""
before_install:
- lsb_release -a
- uname -a
before_script:
- phpize
- ./configure --enable-suhosin-experimental
- make -j2 CFLAGS="-DSUHOSIN_DEBUG=1"
- phpenv config-rm xdebug.ini
script:
- make test NO_INTERACTION=1
================================================
FILE: CREDITS
================================================
suhosin
Stefan Esser
================================================
FILE: Changelog
================================================
2016-xx-xx - 0.9.39dev2
- some improvements for Windows (NewEraCracker)
- fixes for test cases (NewEraCracker)
- new feature: suhosin.log.max_error_length to limit the error output
- fixed function_exists wrapper to ignore backslash-prefixes (#92)
- backport of PHP bug 71152: mt_rand() returns the different values from original mt19937ar.c
- removed dead code
- better debian integration
- fixed perdir checks
- merged PHP changes to RFC1867 code
2015-05-21 - 0.9.38
- removed code compatibility for PHP <5.4 (lots of code + ifdefs)
- allow https location for suhosin.filter.action
- fixed newline detection for suhosin.mail.protect
- Added suhosin.upload.max_newlines to protect againt DOS attack via many
MIME headers in RFC1867 uploads (CVE-2015-4024)
- mail related test cases now work on linux
2014-12-12 - 0.9.37.1
- Changed version string to 0.9.37.1 (without -dev)
- Relaxed array index blacklist (removed '-') due to wordpress incompatibility
2014-12-03 - 0.9.37
- Added SQL injection protection for Mysqli and several test cases
- Added wildcard matching for SQL username
- Added check for SQL username to only contain valid characters (>= ASCII 32)
- Test cases for user_prefix and user_postfix
- Added experimental PDO support
- SQL checks other than mysql (Mysqli + old-style) must be enabled with
configure --enable-suhosin-experimental, e.g. MSSQL.
- disallow_ws now matches all single-byte whitespace characters
- remove_binary and disallow_binary now optionally allow UTF-8.
- Introduced suhosin.upload.allow_utf8 (experimental)
- Reimplemented suhosin_get_raw_cookies()
- Fixed potential segfault for disable_display_errors=fail (only on ARM)
- Fixed potential NULL-pointer dereference with func.blacklist and logging
- Logging timestamps are localtime instead of gmt now (thanks to mkrokos)
- Added new array index filter (character whitelist/blacklist)
- Set default array index blacklist to '"+-<>;()
- Added option to suppress date/time for suhosin file logging (suhosin.log.file.time=0)
- Added simple script to create binary Debian package
- Fixed additional recursion problems with session handler
- Suhosin now depends on php_session.h instead of version-specific struct code
2014-06-10 - 0.9.36
- Added better handling of non existing/non executable shell scripts
- Added protection against XSS/SQL/Other Injections through User-Agent HTTP header
- Fix variable logging statistics outputting on every include - ticket: #37
- Added more entropy from /dev/urandom to internal random seeding (64 bit => 256 bit)
- Added non initialized stack variables to random seeding
- Added php_win32_get_random_bytes for windows compatibility in random seeding
- Added suhosin.rand.seedingkey for INI supplied additional entropy string (idea DavisNT)
- Added suhosin.rand.reseed_every_request to allow reseeding on every request (idea DavisNT)
- Changed that calls to srand() / mt_srand() will trigger auto reseeding (idea DavisNT)
- Fixed problems with SessionHandler() class and endless recursions
- Added LICENSE file to make distributions happy
2014-02-24 - 0.9.35
- From now only PHP >= 5.4 is officially supported
- Fix problems with the hard memory_limit on 64 bit systems
- Fix problems with user space session handler due to change in PHP 5.4.0
- Add changes in PHP 5.5 session handlers structures for PHP 5.5 compability
- Fix std post handler for PHP >= 5.3.11
- Fix suhosin logo in phpinfo() for PHP 5.5
- Change fileupload handling for PHP >= 5.4.0 to use an up to date RFC1867 replacement code
- Adapted suhosin to PHP 5.5 executor
- Added some test cases for various things
- Added suhosin.log.stdout to log to stdout (for debugging purposes only)
- Add ini_set() fail mode to suhosin.disable.display_errors
- Fix suhosin.get/post/cookie.max_totalname_length filter
- Refactor array index handling in filter to make it work always
- Added support for PHP 5.6.0alpha2
- WARNING: FUNCTION WHITELISTS/BLACKLISTS NEVER WORKED CORRECTLY WITH PHP < 5.5
2012-02-12 - 0.9.34
- Added initial support for PHP 5.4.0
- Fix include whitelist and blacklist to support shemes with dots in their names
- Fix read after efree() that lets function_exists() malfunction
- Fix build with clang compiler
- Added a request variable drop statistic log message
2012-01-19 - 0.9.33
- Make clear that suhosin is incompatible to mbstring.encoding_translation=On
- Stop mbstring extension from replacing POST handlers
- Added detection of extensions manipulating POST handlers
- Fixed environment variables for logging do not go through the filter extension anymore
- Fixed stack based buffer overflow in transparent cookie encryption (see separate advisory)
- Fixed that disabling HTTP response splitting protection also disabled NUL byte protection in HTTP headers
- Removed crypt() support - because not used for PHP >= 5.3.0 anyway
2010-07-23 - 0.9.32.1
- Fixed missing header file resulting in compile errors
2010-07-23 - 0.9.32
- Added support for memory_limit > 2GB
- Fixed missing header file resulting in wrong php_combined_lcg() prototype being used
- Improved random number seed generation more by adding /dev/urandom juice
2010-03-28 - 0.9.31
- Fix ZTS build of session.c
- Increased session identifier entropy by using /dev/urandom if available
2010-03-25 - 0.9.30
- Added line ending characters %0a and %0d to the list of dangerous characters handled
by suhosin.server.encode and suhosin.server.strip
- Fixed crash bug with PHP 5.3.x and session module (due to changed session globals struct)
- Added ! protection to PHP session serializer
- Fixed simulation mode now also affects (dis)allowed functions
- Fixed missing return (1); in random number generator replacements
- Fixed random number generator replacement error case behaviour in PHP 5.3.x
- Fixed error case handling in function_exists() PHP 5.3.x
- Merged changes/fixes in import_request_variables()/extract() from upstream PHP
- Fixed suhosin_header_handler to be PHP 5.3.x compatible
- Merge fixes and new features of PHP's file upload code to suhosin
2009-08-15 - 0.9.29
- Fixing crash bugs with PHP 5.3.0 caused by unexpected NULL in EG(active_symbol_table)
- Added more compatible way to retrieve ext/session globals
- Increased default length and count limit for POST variables (for people not reading docu)
2009-08-14 - 0.9.28
- Fixed crash bug with PHP 5.2.10 caused by a change in extension load order of ext/session
- Fixed harmless parameter order error in a bogus memset()
- Disable suhosin.session.cryptua by default because of Internet Explorer 8 "features"
- Added suhosin.executor.include.allow_writable_files which can be disabled to disallow
inclusion of files writable by the webserver
2008-08-23 - 0.9.27
- Fixed typo in replacement rand() / mt_rand() that was hidden by LAZY symbol loading
2008-08-22 - 0.9.26
- Fixed problem with suhosin.perdir
Thanks to Hosteurope for tracking this down
- Fixed problems with ext/uploadprogress
Reported by: Christian Stocker
- Added suhosin.srand.ignore and suhosin.mt_srand.ignore (default: on)
- Modified rand()/srand() to use the Mersenne Twister algorithm with separate state
- Added better internal seeding of rand() and mt_rand()
2008-08-06 - 0.9.25
- Fixed PHP 4 compilation problem introduced in 0.9.24
- Fixed PHP 5.3 compilation problem
- Changed PHP default POST handler to PHP's current handler
2008-05-10 - 0.9.24
- Added support for method-calls to function handling
- This fixes white- and blacklist affecting methods with the same name
2008-01-14 - 0.9.23
- Fixed suhosin extension now compiles with snapshots of PHP 5.3
- Fixed crypt() behaves like normal again when there is no salt supplied
2007-12-01 - 0.9.22
- Removed LFS warning message because it crashed on several systems
2007-11-30 - 0.9.21
- Fixed function_exists() now checks the Suhosin permissions
- Fixed crypt() salt no longer uses Blowfish by default
- Fixed .htaccess/perdir support
- Fixed compilation problem on OS/X
- Added protection against some attacks through _SERVER variables
- Added suhosin.server.strip and suhosin.server.encode
- Added error message that warns about the LFS binary incompatibility
2007-05-19 - 0.9.20
- Added protection flags against whitespace at variable start
- Added mutex around crypt() to close the PHP crypt()
thread safety vulnerability class
- Improved HTTP Response Splitting Protection
- Changed default maximum array depth to 50 for GPCR
- Fixed possible endless loop in file logging
- Fixed file locking in file logging
2007-05-01 - 0.9.19
- Fixed typo in HTTP header protection (only during simulation mode)
Reported by: Ilia Alshanetsky
- Fixed wrong \0 termination in cookie decryptor
- Fixed possible crash in SERVER variables protection when SAPI=embedded
Fix provided by: Olivier Blin/Mandriva Linux
- Added possibility to en-/disable INI_PERDIR
Problem reported by: Ilia Alshanetsky
- Added PHP Warning when disabled function is called
- Added examples for new configuration option in suhosin.ini
2007-03-06 - 0.9.18
- Fixed session double hooking in edge case
- Added additional crash protection for PHP's session module
2007-03-04 - 0.9.17
- Added a suhosin.ini example configuration
Thanks to Mandriva Linux for supplying us with one
- Added new logging device: file
- Fixed that suhosin.filter.action did not affect POST limits
- Fixed behaviour of request variable limit to be an upper limit
for the other settings instead of being additive limit
- Fixed hard_memory_limit bypass due to casting bug in PHP
Problem was found by: Ilia Alshanetsky
- Fixed some sql prefix/postfix problems
- Added experimental SQL injection heuristic
2006-12-02 - 0.9.16
- Added suhosin.stealth which controls if suhosin loads in
stealth mode when it is not the only zend_extension
(Required for full compatibility with certain encoders
that consider open source untrusted. e.g. ionCube, Zend)
- Activate suhosin.stealth by default
- Fixed that Suhosin tries handling functions disabled by
disable_function. In v0.9.15 it was impossible to disable
phpinfo() with disable_function.
Problem was found by: Thorsten Schifferdecker
2006-11-28 - 0.9.15
- Added a transparent protection for open phpinfo() pages by
adding an HTML META ROBOTS tag to the output that forbids
indexing and archiving
2006-11-22 - 0.9.14
- Drop wrongly decrypted cookies instead of leaving them empty
- Fix another problem with urlencoded cookie names
- Fix compilation problem with PHP4
- Added better regression to the release process to stop
compilation and missing symbol problems
2006-11-20 - 0.9.13
- More compatible support for ap_php_snprintf() for old PHP
- Changed phpinfo() output to put suhosin logo into a data: URL
for Opera and Gecko based browsers when expose_php=off
2006-11-14 - 0.9.12
- Adding ap_php_snprintf() when compiling against PHP 4.3.9
- Added suhosin.protectkey to remove cryptkeys from phpinfo() output
- Disabled suhosin.cookie.encrypt in default install
- Fixed static compilation against PHP 5.2.0
2006-11-06 - 0.9.11
- Fixed input filter for simulation mode
2006-10-26 - 0.9.10
- Fixed ZTS compile problem in new code
- Fixed PHP4 compile problem in new code
2006-10-25 - 0.9.9
- Fixed mail() protection that failed to detect some injected headers
- Fixed cookie decryption to not potentially trash apache memory
- Fixed cookie enctyption to handle url encoded names correctly
- Added suhosin.cookie/session.checkraddr
- Added suhosin.cookie.cryptlist
- Added suhosin.cookie.plainlist
- Added suhosin_encrypt_cookie function for JS
- Added suhosin_get_raw_cookies function
- Changed dropped variable error messages
2006-10-08 - 0.9.8
- Fixed a PHP4 ZTS compile problem
2006-10-08 - 0.9.7
- Moved input handler hooking to a later place to ensure better compatibility
with 3rd party extensions
- Fixed a problem with overlong mail headers in mail protection
- Fixed a problem with empty log/verification script names
- Fixed a PHP4 compile problem with old gcc/in ZTS mode
- Added mbregex.h from PHP4 to solve compile problems on systesm with broken
header installations
2006-10-02 - 0.9.6
- Disallow symlink() when open_basedir (activated by default)
- Fix a problem with compilation in Visual Studio
2006-09-29 - 0.9.5
- Added missing logo file
- Added suhosin.apc_bug_workaround flag to enable compatibility with buggy APC 3.0.12x
2006-09-29 - 0.9.4
- Added version number and logo to phpinfo() output
- Fixed that all uploaded files are dropped after a single one was disallowed
- Added undocumented suhosin.coredump flag to tell suhosin to dump core instead
of logging S_MEMORY events
- Disable handling of rfc1867 mbstring decoding
2006-09-24 - 0.9.3
- Added protection against endless recursion for suhosin.log.phpscript
- Added possibility to disable open_basedir and safe_mode for suhosin.log.phpscript
- Added suhosin.executor.include.max_traversal to stop directory traversal includes
2006-09-19 - 0.9.2
- Fixes broken rfc1867 fileupload hook
- Changed definition of binary to: 0..31, 128..255 except whitespace
- Added suhosin.log.phpscript(.name) directive to log to a PHP script
2006-09-16 - 0.9.1
- A bunch of changes to compile and work on Windows
2006-09-09 - BETA
- Added decryption of HTTP_COOKIE
- Fixed a last problem in suhosin_strcasestr() helper function
2006-09-08 - BETA
- Fixed a problem within suhosin_strcasestr() because it broke
URL checks
2006-09-07 - BETA
- CVS version of PHP 5.2.0 was changed to support incasesensitive
URLs, support for this in suhosin added
- Fixed a problem when preg_replace() was called with more than
4 parameters
================================================
FILE: LICENSE
================================================
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2014 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at
<http://www.zend.com>.
================================================
FILE: README.md
================================================
[](https://travis-ci.org/sektioneins/suhosin)
[](https://gitter.im/sektioneins/suhosin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Suhosin
Suhosin (pronounced 'su-ho-shin') is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core.
================================================
FILE: aes.c
================================================
/* Rijndael Block Cipher - rijndael.c
Written by Mike Scott 21st April 1999
mike@compapp.dcu.ie
An alternative faster version is implemented in MIRACL
ftp://ftp.computing.dcu.ie/pub/crypto/miracl.zip
Copyright (c) 1999 Mike Scott
Simply compile and run, e.g.
cl /O2 rijndael.c (Microsoft C)
bcc32 /O2 rijndael.c (Borland C)
gcc -O2 rijndael.c -o rijndael (Gnu C)
Compiles and runs fine as a C++ program also.
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.
Inspiration from Brian Gladman's implementation is acknowledged.
Written for clarity, rather than speed.
Assumes long is 32 bit quantity.
Full implementation.
Endian indifferent.
*/
#include "php.h"
#include "php_suhosin.h"
/* rotates x one bit to the left */
#define ROTL(x) (((x)>>7)|((x)<<1))
/* Rotates 32-bit word left by 1, 2 or 3 byte */
#define ROTL8(x) (((x)<<8)|((x)>>24))
#define ROTL16(x) (((x)<<16)|((x)>>16))
#define ROTL24(x) (((x)<<24)|((x)>>8))
/* Fixed Data */
static BYTE InCo[4]={0xB,0xD,0x9,0xE}; /* Inverse Coefficients */
static BYTE fbsub[256];
static BYTE rbsub[256];
static BYTE ptab[256],ltab[256];
static WORD ftable[256];
static WORD rtable[256];
static WORD rco[30];
/* Parameter-dependent data */
static int Nk,Nb,Nr;
static WORD pack(BYTE *b)
{ /* pack bytes into a 32-bit Word */
return ((WORD)b[3]<<24)|((WORD)b[2]<<16)|((WORD)b[1]<<8)|(WORD)b[0];
}
static void unpack(WORD a,BYTE *b)
{ /* unpack bytes from a word */
b[0]=(BYTE)a;
b[1]=(BYTE)(a>>8);
b[2]=(BYTE)(a>>16);
b[3]=(BYTE)(a>>24);
}
static BYTE xtime(BYTE a)
{
BYTE b;
if (a&0x80) b=0x1B;
else b=0;
a<<=1;
a^=b;
return a;
}
static BYTE bmul(BYTE x,BYTE y)
{ /* x.y= AntiLog(Log(x) + Log(y)) */
if (x && y) return ptab[(ltab[x]+ltab[y])%255];
else return 0;
}
static WORD SubByte(WORD a)
{
BYTE b[4];
unpack(a,b);
b[0]=fbsub[b[0]];
b[1]=fbsub[b[1]];
b[2]=fbsub[b[2]];
b[3]=fbsub[b[3]];
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);
return bmul(xb[0],yb[0])^bmul(xb[1],yb[1])^bmul(xb[2],yb[2])^bmul(xb[3],yb[3]);
}
static WORD InvMixCol(WORD x)
{ /* matrix Multiplication */
WORD y,m;
BYTE b[4];
m=pack(InCo);
b[3]=product(m,x);
m=ROTL24(m);
b[2]=product(m,x);
m=ROTL24(m);
b[1]=product(m,x);
m=ROTL24(m);
b[0]=product(m,x);
y=pack(b);
return y;
}
static BYTE ByteSub(BYTE x)
{
BYTE y=ptab[255-ltab[x]]; /* multiplicative inverse */
x=y; x=ROTL(x);
y^=x; x=ROTL(x);
y^=x; x=ROTL(x);
y^=x; x=ROTL(x);
y^=x; y^=0x63;
return y;
}
void suhosin_aes_gentables()
{ /* generate tables */
int i;
BYTE y,b[4];
/* use 3 as primitive root to generate power and log tables */
ltab[0]=0;
ptab[0]=1; ltab[1]=0;
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;
rbsub[0x63]=0;
for (i=1;i<256;i++)
{
y=ByteSub((BYTE)i);
fbsub[i]=y; rbsub[y]=i;
}
for (i=0,y=1;i<30;i++)
{
rco[i]=y;
y=xtime(y);
}
/* calculate forward and reverse tables */
for (i=0;i<256;i++)
{
y=fbsub[i];
b[3]=y^xtime(y); b[2]=y;
b[1]=y; b[0]=xtime(y);
ftable[i]=pack(b);
y=rbsub[i];
b[3]=bmul(InCo[0],y); b[2]=bmul(InCo[1],y);
b[1]=bmul(InCo[2],y); b[0]=bmul(InCo[3],y);
rtable[i]=pack(b);
}
}
void suhosin_aes_gkey(int nb,int nk,char *key TSRMLS_DC)
{ /* blocksize=32*nb bits. Key=32*nk bits */
/* currently nb,bk = 4, 6 or 8 */
/* key comes as 4*Nk bytes */
/* Key Scheduler. Create expanded encryption key */
int i,j,k,m,N;
int C1,C2,C3;
WORD CipherKey[8];
Nb=nb; Nk=nk;
/* Nr is number of rounds */
if (Nb>=Nk) Nr=6+Nb;
else Nr=6+Nk;
C1=1;
if (Nb<8) { C2=2; C3=3; }
else { C2=3; C3=4; }
/* pre-calculate forward and reverse increments */
for (m=j=0;j<nb;j++,m+=3)
{
SUHOSIN_G(fi)[m]=(j+C1)%nb;
SUHOSIN_G(fi)[m+1]=(j+C2)%nb;
SUHOSIN_G(fi)[m+2]=(j+C3)%nb;
SUHOSIN_G(ri)[m]=(nb+j-C1)%nb;
SUHOSIN_G(ri)[m+1]=(nb+j-C2)%nb;
SUHOSIN_G(ri)[m+2]=(nb+j-C3)%nb;
}
N=Nb*(Nr+1);
for (i=j=0;i<Nk;i++,j+=4)
{
CipherKey[i]=pack((BYTE *)&key[j]);
}
for (i=0;i<Nk;i++) SUHOSIN_G(fkey)[i]=CipherKey[i];
for (j=Nk,k=0;j<N;j+=Nk,k++)
{
SUHOSIN_G(fkey)[j]=SUHOSIN_G(fkey)[j-Nk]^SubByte(ROTL24(SUHOSIN_G(fkey)[j-1]))^rco[k];
if (Nk<=6)
{
for (i=1;i<Nk && (i+j)<N;i++)
SUHOSIN_G(fkey)[i+j]=SUHOSIN_G(fkey)[i+j-Nk]^SUHOSIN_G(fkey)[i+j-1];
}
else
{
for (i=1;i<4 &&(i+j)<N;i++)
SUHOSIN_G(fkey)[i+j]=SUHOSIN_G(fkey)[i+j-Nk]^SUHOSIN_G(fkey)[i+j-1];
if ((j+4)<N) SUHOSIN_G(fkey)[j+4]=SUHOSIN_G(fkey)[j+4-Nk]^SubByte(SUHOSIN_G(fkey)[j+3]);
for (i=5;i<Nk && (i+j)<N;i++)
SUHOSIN_G(fkey)[i+j]=SUHOSIN_G(fkey)[i+j-Nk]^SUHOSIN_G(fkey)[i+j-1];
}
}
/* now for the expanded decrypt key in reverse order */
for (j=0;j<Nb;j++) SUHOSIN_G(rkey)[j+N-Nb]=SUHOSIN_G(fkey)[j];
for (i=Nb;i<N-Nb;i+=Nb)
{
k=N-Nb-i;
for (j=0;j<Nb;j++) SUHOSIN_G(rkey)[k+j]=InvMixCol(SUHOSIN_G(fkey)[i+j]);
}
for (j=N-Nb;j<N;j++) SUHOSIN_G(rkey)[j-N+Nb]=SUHOSIN_G(fkey)[j];
}
/* There is an obvious time/space trade-off possible here. *
* Instead of just one ftable[], I could have 4, the other *
* 3 pre-rotated to save the ROTL8, ROTL16 and ROTL24 overhead */
void suhosin_aes_encrypt(char *buff TSRMLS_DC)
{
int i,j,k,m;
WORD a[8],b[8],*x,*y,*t;
for (i=j=0;i<Nb;i++,j+=4)
{
a[i]=pack((BYTE *)&buff[j]);
a[i]^=SUHOSIN_G(fkey)[i];
}
k=Nb;
x=a; y=b;
/* State alternates between a and b */
for (i=1;i<Nr;i++)
{ /* Nr is number of rounds. May be odd. */
/* if Nb is fixed - unroll this next
loop and hard-code in the values of fi[] */
for (m=j=0;j<Nb;j++,m+=3)
{ /* deal with each 32-bit element of the State */
/* This is the time-critical bit */
y[j]=SUHOSIN_G(fkey)[k++]^ftable[(BYTE)x[j]]^
ROTL8(ftable[(BYTE)(x[SUHOSIN_G(fi)[m]]>>8)])^
ROTL16(ftable[(BYTE)(x[SUHOSIN_G(fi)[m+1]]>>16)])^
ROTL24(ftable[x[SUHOSIN_G(fi)[m+2]]>>24]);
}
t=x; x=y; y=t; /* swap pointers */
}
/* Last Round - unroll if possible */
for (m=j=0;j<Nb;j++,m+=3)
{
y[j]=SUHOSIN_G(fkey)[k++]^(WORD)fbsub[(BYTE)x[j]]^
ROTL8((WORD)fbsub[(BYTE)(x[SUHOSIN_G(fi)[m]]>>8)])^
ROTL16((WORD)fbsub[(BYTE)(x[SUHOSIN_G(fi)[m+1]]>>16)])^
ROTL24((WORD)fbsub[x[SUHOSIN_G(fi)[m+2]]>>24]);
}
for (i=j=0;i<Nb;i++,j+=4)
{
unpack(y[i],(BYTE *)&buff[j]);
x[i]=y[i]=0; /* clean up stack */
}
return;
}
void suhosin_aes_decrypt(char *buff TSRMLS_DC)
{
int i,j,k,m;
WORD a[8],b[8],*x,*y,*t;
for (i=j=0;i<Nb;i++,j+=4)
{
a[i]=pack((BYTE *)&buff[j]);
a[i]^=SUHOSIN_G(rkey)[i];
}
k=Nb;
x=a; y=b;
/* State alternates between a and b */
for (i=1;i<Nr;i++)
{ /* Nr is number of rounds. May be odd. */
/* if Nb is fixed - unroll this next
loop and hard-code in the values of ri[] */
for (m=j=0;j<Nb;j++,m+=3)
{ /* This is the time-critical bit */
y[j]=SUHOSIN_G(rkey)[k++]^rtable[(BYTE)x[j]]^
ROTL8(rtable[(BYTE)(x[SUHOSIN_G(ri)[m]]>>8)])^
ROTL16(rtable[(BYTE)(x[SUHOSIN_G(ri)[m+1]]>>16)])^
ROTL24(rtable[x[SUHOSIN_G(ri)[m+2]]>>24]);
}
t=x; x=y; y=t; /* swap pointers */
}
/* Last Round - unroll if possible */
for (m=j=0;j<Nb;j++,m+=3)
{
y[j]=SUHOSIN_G(rkey)[k++]^(WORD)rbsub[(BYTE)x[j]]^
ROTL8((WORD)rbsub[(BYTE)(x[SUHOSIN_G(ri)[m]]>>8)])^
ROTL16((WORD)rbsub[(BYTE)(x[SUHOSIN_G(ri)[m+1]]>>16)])^
ROTL24((WORD)rbsub[x[SUHOSIN_G(ri)[m+2]]>>24]);
}
for (i=j=0;i<Nb;i++,j+=4)
{
unpack(y[i],(BYTE *)&buff[j]);
x[i]=y[i]=0; /* clean up stack */
}
return;
}
/*
static int main()
{
int i,nb,nk;
char key[32];
char block[32];
gentables();
for (i=0;i<32;i++) key[i]=0;
key[0]=1;
for (i=0;i<32;i++) block[i]=i;
for (nb=4;nb<=8;nb+=2)
for (nk=4;nk<=8;nk+=2)
{
printf("\nBlock Size= %d bits, Key Size= %d bits\n",nb*32,nk*32);
gkey(nb,nk,key);
printf("Plain= ");
for (i=0;i<nb*4;i++) printf("%02x",block[i]);
printf("\n");
encrypt(block);
printf("Encrypt= ");
for (i=0;i<nb*4;i++) printf("%02x",(unsigned char)block[i]);
printf("\n");
decrypt(block);
printf("Decrypt= ");
for (i=0;i<nb*4;i++) printf("%02x",block[i]);
printf("\n");
}
return 0;
}
*/
================================================
FILE: config.m4
================================================
dnl $Id: config.m4,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
dnl config.m4 for extension suhosin
PHP_ARG_ENABLE(suhosin, whether to enable suhosin support,
[ --enable-suhosin Enable suhosin support])
if test "$PHP_SUHOSIN" != "no"; then
PHP_NEW_EXTENSION(suhosin, suhosin.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867_new.c log.c header.c execute.c ex_imp.c session.c aes.c crypt.c pledge.c, $ext_shared)
fi
PHP_ARG_ENABLE(suhosin-experimental, whether to enable experimental suhosin features,
[ --enable-suhosin-experimental Enable experimental suhosin features], no, no)
if test "$PHP_SUHOSIN_EXPERIMENTAL" != "no"; then
AC_DEFINE(SUHOSIN_EXPERIMENTAL, 1, [Whether to enable experimental suhosin features])
fi
================================================
FILE: config.w32
================================================
// $Id: config.w32,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
// vim:ft=javascript
ARG_ENABLE("suhosin", "whether to enable suhosin support", "yes");
if (PHP_SUHOSIN == "yes") {
EXTENSION("suhosin", "suhosin.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867_new.c log.c header.c execute.c ex_imp.c session.c aes.c crypt.c");
ARG_ENABLE("suhosin-experimental", "Enable experimental suhosin features", "no");
if (PHP_SUHOSIN_EXPERIMENTAL != "no") {
ADD_FLAG("CFLAGS_SUHOSIN", "/D SUHOSIN_EXPERIMENTAL");
AC_DEFINE("SUHOSIN_EXPERIMENTAL", 1, "Whether to enable experimental suhosin features");
}
}
================================================
FILE: crypt.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Stefan Esser <sesser@sektioneins.de> |
| Ben Fuhrmannek <ben.fuhrmannek@sektioneins.de> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "TSRM.h"
#include "php_suhosin.h"
#include "ext/standard/base64.h"
#include "sha256.h"
static void suhosin_get_ipv4(char *buf TSRMLS_DC)
{
char *raddr = suhosin_getenv(ZEND_STRL("REMOTE_ADDR") TSRMLS_CC);
int i;
if (raddr == NULL) {
memset(buf, 0, 4);
return;
}
for (i=0; i<4; i++) {
if (raddr[0] == 0) {
buf[i] = 0;
} else {
buf[i] = strtol(raddr, &raddr, 10);
if (raddr[0] == '.') {
raddr++;
}
}
}
}
char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key TSRMLS_DC)
{
int padded_len, i, slen;
unsigned char *crypted, *tmp;
unsigned int check = 0x13579BDF;
if (str == NULL) {
return NULL;
}
if (len == 0) {
return estrndup("", 0);
}
suhosin_aes_gkey(4,8,key TSRMLS_CC);
padded_len = ((len+15) & ~0xF);
crypted = emalloc(16+padded_len+1);
memset(crypted, 0xff, 16+padded_len+1);
memcpy(crypted+16, str, len+1);
/* calculate check value */
for (i = 0; i<vlen; i++) {
check = (check << 3) | (check >> (32-3));
check += check << 1;
check ^= (unsigned char)var[i];
}
for (i = 0; i<len; i++) {
check = (check << 3) | (check >> (32-3));
check += check << 1;
check ^= (unsigned char)str[i];
}
/* store ip value */
suhosin_get_ipv4((char *)crypted+4 TSRMLS_CC);
/* store check value */
crypted[8] = check & 0xff;
crypted[9] = (check >> 8) & 0xff;
crypted[10] = (check >> 16) & 0xff;
crypted[11] = (check >> 24) & 0xff;
/* store original length */
crypted[12] = len & 0xff;
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;
for (j=0; j<16; j++) tmp[j] ^= tmp[j-16];
}
suhosin_aes_encrypt((char *)tmp TSRMLS_CC);
}
tmp = php_base64_encode(crypted, padded_len+16, NULL);
efree(crypted);
slen=strlen((char *)tmp);
for (i=0; i<slen; i++) {
switch (tmp[i]) {
case '/': tmp[i]='-'; break;
case '=': tmp[i]='.'; break;
case '+': tmp[i]='_'; break;
}
}
return (char *)tmp;
}
char *suhosin_decrypt_string(char *str, int padded_len, char *var, int vlen, char *key, int *orig_len, int check_ra TSRMLS_DC)
{
int len, i, o_len, invalid = 0;
unsigned char *decrypted, *tmp;
unsigned int check = 0x13579BDF;
char buf[4];
if (str == NULL) {
return NULL;
}
if (padded_len == 0) {
if (orig_len) {
*orig_len = 0;
}
return estrndup("", 0);
}
suhosin_aes_gkey(4,8,key TSRMLS_CC);
for (i=0; i<padded_len; i++) {
switch (str[i]) {
case '-': str[i]='/'; break;
case '.': str[i]='='; break;
case '_': str[i]='+'; break;
}
}
decrypted = php_base64_decode((unsigned char *)str, padded_len, &len);
if (decrypted == NULL || len < 2*16 || (len % 16) != 0) {
error_out:
if (decrypted != NULL) {
efree(decrypted);
}
if (orig_len) {
*orig_len = 0;
}
return NULL;
}
for (i=len-16, tmp=decrypted+i; i>=0; i-=16, tmp-=16) {
suhosin_aes_decrypt((char *)tmp TSRMLS_CC);
if (i > 0) {
int j;
for (j=0; j<16; j++) tmp[j] ^= tmp[j-16];
}
}
/* retrieve orig_len */
o_len = decrypted[15];
o_len <<= 8;
o_len |= decrypted[14];
o_len <<= 8;
o_len |= decrypted[13];
o_len <<= 8;
o_len |= decrypted[12];
if (o_len < 0 || o_len > len-16) {
goto error_out;
}
/* calculate check value */
for (i = 0; i<vlen; i++) {
check = (check << 3) | (check >> (32-3));
check += check << 1;
check ^= (unsigned char)var[i];
}
for (i = 0; i<o_len; i++) {
check = (check << 3) | (check >> (32-3));
check += check << 1;
check ^= decrypted[16+i];
}
/* check value */
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 > 0) {
if (check_ra > 4) {
check_ra = 4;
}
suhosin_get_ipv4(&buf[0] TSRMLS_CC);
if (memcmp(buf, decrypted+4, check_ra) != 0) {
goto error_out;
}
}
if (invalid) {
goto error_out;
}
if (orig_len) {
*orig_len = o_len;
}
memmove(decrypted, decrypted+16, o_len);
decrypted[o_len] = 0;
/* we do not realloc() here because 16 byte less
is simply not worth the overhead */
return (char *)decrypted;
}
char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, char *cryptkey TSRMLS_DC)
{
char *_ua = NULL;
char *_dr = NULL;
char *_ra = NULL;
suhosin_SHA256_CTX ctx;
if (ua) {
_ua = suhosin_getenv(ZEND_STRL("HTTP_USER_AGENT") TSRMLS_CC);
}
if (dr) {
_dr = suhosin_getenv(ZEND_STRL("DOCUMENT_ROOT") TSRMLS_CC);
}
if (raddr > 0) {
_ra = suhosin_getenv(ZEND_STRL("REMOTE_ADDR") TSRMLS_CC);
}
SDEBUG("(suhosin_generate_key) KEY: %s - UA: %s - DR: %s - RA: %s", key,_ua,_dr,_ra);
suhosin_SHA256Init(&ctx);
if (key == NULL || *key == 0) {
suhosin_SHA256Update(&ctx, (unsigned char*)"D3F4UL7", strlen("D3F4UL7"));
} else {
suhosin_SHA256Update(&ctx, (unsigned char*)key, strlen(key));
}
if (_ua) {
suhosin_SHA256Update(&ctx, (unsigned char*)_ua, strlen(_ua));
}
if (_dr) {
suhosin_SHA256Update(&ctx, (unsigned char*)_dr, strlen(_dr));
}
if (_ra) {
if (raddr >= 4) {
suhosin_SHA256Update(&ctx, (unsigned char*)_ra, strlen(_ra));
} else {
long dots = 0;
char *tmp = _ra;
while (*tmp) {
if (*tmp == '.') {
dots++;
if (dots == raddr) {
break;
}
}
tmp++;
}
suhosin_SHA256Update(&ctx, (unsigned char*)_ra, tmp-_ra);
}
}
suhosin_SHA256Final((unsigned char *)cryptkey, &ctx);
cryptkey[32] = 0; /* uhmm... not really a string */
return cryptkey;
}
================================================
FILE: ex_imp.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/*
$Id: ex_imp.c,v 1.2 2008-01-04 11:23:47 sesser Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_suhosin.h"
#include "ext/standard/php_smart_str.h"
#include "ext/standard/php_var.h"
#define EXTR_OVERWRITE 0
#define EXTR_SKIP 1
#define EXTR_PREFIX_SAME 2
#define EXTR_PREFIX_ALL 3
#define EXTR_PREFIX_INVALID 4
#define EXTR_PREFIX_IF_EXISTS 5
#define EXTR_IF_EXISTS 6
#define EXTR_REFS 0x100
static int php_valid_var_name(char *var_name, int len) /* {{{ */
{
int i, ch;
if (!var_name)
return 0;
/* These are allowed as first char: [a-zA-Z_\x7f-\xff] */
ch = (int)((unsigned char *)var_name)[0];
if (var_name[0] != '_' &&
(ch < 65 /* A */ || /* Z */ ch > 90) &&
(ch < 97 /* a */ || /* z */ ch > 122) &&
(ch < 127 /* 0x7f */ || /* 0xff */ ch > 255)
) {
return 0;
}
/* And these as the rest: [a-zA-Z0-9_\x7f-\xff] */
if (len > 1) {
for (i = 1; i < len; i++) {
ch = (int)((unsigned char *)var_name)[i];
if (var_name[i] != '_' &&
(ch < 48 /* 0 */ || /* 9 */ ch > 57) &&
(ch < 65 /* A */ || /* Z */ ch > 90) &&
(ch < 97 /* a */ || /* z */ ch > 122) &&
(ch < 127 /* 0x7f */ || /* 0xff */ ch > 255)
) {
return 0;
}
}
}
if (suhosin_is_protected_varname(var_name, len)) {
return 0;
}
return 1;
}
/* {{{ proto int extract(array var_array [, int extract_type [, string prefix]])
Imports variables into symbol table from an array */
PHP_FUNCTION(suhosin_extract)
{
zval *var_array, *prefix = NULL;
long extract_type = EXTR_OVERWRITE;
zval **entry, *data;
char *var_name;
ulong num_key;
uint var_name_len;
int var_exists, key_type, count = 0;
int extract_refs = 0;
HashPosition pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|lz/", &var_array, &extract_type, &prefix) == FAILURE) {
return;
}
extract_refs = (extract_type & EXTR_REFS);
extract_type &= 0xff;
if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid extract type");
return;
}
if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS() < 3) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "specified extract type requires the prefix parameter");
return;
}
if (prefix) {
convert_to_string(prefix);
if (Z_STRLEN_P(prefix) && !php_valid_var_name(Z_STRVAL_P(prefix), Z_STRLEN_P(prefix))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "prefix is not a valid identifier");
return;
}
}
if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C);
}
/* var_array is passed by ref for the needs of EXTR_REFS (needs to
* work on the original array to create refs to its members)
* simulate pass_by_value if EXTR_REFS is not used */
if (!extract_refs) {
SEPARATE_ARG_IF_REF(var_array);
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(var_array), (void **)&entry, &pos) == SUCCESS) {
zval final_name;
ZVAL_NULL(&final_name);
key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &var_name, &var_name_len, &num_key, 0, &pos);
var_exists = 0;
if (key_type == HASH_KEY_IS_STRING) {
var_name_len--;
var_exists = zend_hash_exists(EG(active_symbol_table), var_name, var_name_len + 1);
} else if (key_type == HASH_KEY_IS_LONG && (extract_type == EXTR_PREFIX_ALL || extract_type == EXTR_PREFIX_INVALID)) {
zval num;
ZVAL_LONG(&num, num_key);
convert_to_string(&num);
php_prefix_varname(&final_name, prefix, Z_STRVAL(num), Z_STRLEN(num), 1 TSRMLS_CC);
zval_dtor(&num);
} else {
zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos);
continue;
}
switch (extract_type) {
case EXTR_IF_EXISTS:
if (!var_exists) break;
/* break omitted intentionally */
case EXTR_OVERWRITE:
/* GLOBALS protection */
if (var_exists && var_name_len == sizeof("GLOBALS") && !strcmp(var_name, "GLOBALS")) {
break;
}
if (var_exists && var_name_len == sizeof("this") && !strcmp(var_name, "this") && EG(scope) && EG(scope)->name_length != 0) {
break;
}
ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
break;
case EXTR_PREFIX_IF_EXISTS:
if (var_exists) {
php_prefix_varname(&final_name, prefix, var_name, var_name_len, 1 TSRMLS_CC);
}
break;
case EXTR_PREFIX_SAME:
if (!var_exists && var_name_len != 0) {
ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
}
/* break omitted intentionally */
case EXTR_PREFIX_ALL:
if (Z_TYPE(final_name) == IS_NULL && var_name_len != 0) {
php_prefix_varname(&final_name, prefix, var_name, var_name_len, 1 TSRMLS_CC);
}
break;
case EXTR_PREFIX_INVALID:
if (Z_TYPE(final_name) == IS_NULL) {
if (!php_valid_var_name(var_name, var_name_len)) {
php_prefix_varname(&final_name, prefix, var_name, var_name_len, 1 TSRMLS_CC);
} else {
ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
}
}
break;
default:
if (!var_exists) {
ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
}
break;
}
if (Z_TYPE(final_name) != IS_NULL && php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
if (extract_refs) {
zval **orig_var;
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
zval_add_ref(entry);
if (zend_hash_find(EG(active_symbol_table), Z_STRVAL(final_name), Z_STRLEN(final_name) + 1, (void **) &orig_var) == SUCCESS) {
zval_ptr_dtor(orig_var);
*orig_var = *entry;
} else {
zend_hash_update(EG(active_symbol_table), Z_STRVAL(final_name), Z_STRLEN(final_name) + 1, (void **) entry, sizeof(zval *), NULL);
}
} else {
MAKE_STD_ZVAL(data);
*data = **entry;
zval_copy_ctor(data);
ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), Z_STRVAL(final_name), Z_STRLEN(final_name) + 1, data, 1, 0);
}
count++;
}
zval_dtor(&final_name);
zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos);
}
if (!extract_refs) {
zval_ptr_dtor(&var_array);
}
RETURN_LONG(count);
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(suhosin_arginfo_extract, 0, 0, 1)
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, arg) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_INFO(0, extract_type)
ZEND_ARG_INFO(0, prefix)
ZEND_END_ARG_INFO()
/* {{{ suhosin_ex_imp_functions[]
*/
zend_function_entry suhosin_ex_imp_functions[] = {
PHP_NAMED_FE(extract, PHP_FN(suhosin_extract), suhosin_arginfo_extract)
{NULL, NULL, NULL}
};
/* }}} */
void suhosin_hook_ex_imp(TSRMLS_D)
{
/* replace the extract and import_request_variables functions */
zend_hash_del(CG(function_table), "extract", sizeof("extract"));
zend_register_functions(NULL, suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC);
}
/*
* 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
*/
================================================
FILE: execute.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/* $Id: execute.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <fcntl.h>
#include "php.h"
#include "php_ini.h"
#include "zend_hash.h"
#include "zend_extensions.h"
#include "ext/standard/info.h"
#include "ext/standard/php_rand.h"
#include "ext/standard/php_lcg.h"
#include "php_suhosin.h"
#include "zend_compile.h"
#include "zend_llist.h"
#include "SAPI.h"
#include "sha256.h"
#ifdef PHP_WIN32
# include "win32/fnmatch.h"
# include "win32/winutil.h"
# include "win32/time.h"
#else
# ifdef HAVE_FNMATCH
# include <fnmatch.h>
# endif
# include <sys/time.h>
#endif
#if PHP_VERSION_ID >= 50500
static void (*old_execute_ex)(zend_execute_data *execute_data TSRMLS_DC);
static void suhosin_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
#endif
static void (*old_execute)(zend_op_array *op_array TSRMLS_DC);
static void suhosin_execute(zend_op_array *op_array TSRMLS_DC);
static void (*old_execute_ZO)(zend_op_array *op_array, long dummy TSRMLS_DC);
static void suhosin_execute_ZO(zend_op_array *op_array, long dummy TSRMLS_DC);
static void *(*zo_set_oe_ex)(void *ptr) = NULL;
/*STATIC zend_op_array* (*old_compile_file)(zend_file_handle* file_handle, int type TSRMLS_DC);
STATIC zend_op_array* suhosin_compile_file(zend_file_handle*, int TSRMLS_DC);*/
#if PHP_VERSION_ID >= 50500
static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC);
static void (*old_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC);
#else
static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
static void (*old_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
#endif
extern zend_extension suhosin_zend_extension_entry;
/* {{{ suhosin_strcasestr */
static char *suhosin_strcasestr(char *haystack, char *needle)
{
unsigned char *t, *h, *n;
h = (unsigned char *) haystack;
conts:
while (*h) {
n = (unsigned char *) needle;
if (toupper(*h++) == toupper(*n++)) {
for (t=h; *n; t++, n++) {
if (toupper(*t) != toupper(*n)) goto conts;
}
return ((char*)h-1);
}
}
return (NULL);
}
/* }}} */
#define SUHOSIN_CODE_TYPE_UNKNOWN 0
#define SUHOSIN_CODE_TYPE_COMMANDLINE 1
#define SUHOSIN_CODE_TYPE_EVAL 2
#define SUHOSIN_CODE_TYPE_REGEXP 3
#define SUHOSIN_CODE_TYPE_ASSERT 4
#define SUHOSIN_CODE_TYPE_CFUNC 5
#define SUHOSIN_CODE_TYPE_SUHOSIN 6
#define SUHOSIN_CODE_TYPE_UPLOADED 7
#define SUHOSIN_CODE_TYPE_0FILE 8
#define SUHOSIN_CODE_TYPE_BLACKURL 9
#define SUHOSIN_CODE_TYPE_BADURL 10
#define SUHOSIN_CODE_TYPE_GOODFILE 11
#define SUHOSIN_CODE_TYPE_BADFILE 12
#define SUHOSIN_CODE_TYPE_LONGNAME 13
#define SUHOSIN_CODE_TYPE_MANYDOTS 14
#define SUHOSIN_CODE_TYPE_WRITABLE 15
#define SUHOSIN_CODE_TYPE_MBREGEXP 16
static int suhosin_check_filename(char *s, int len TSRMLS_DC)
{
char fname[MAXPATHLEN+1];
char *t, *h, *h2, *index, *e;
int tlen, i, count=0;
uint indexlen;
ulong numindex;
zend_bool isOk;
/* check if filename is too long */
if (len > MAXPATHLEN) {
return SUHOSIN_CODE_TYPE_LONGNAME;
}
memcpy(fname, s, len);
fname[len] = 0;
s = (char *)&fname;
e = s + len;
/* check if ASCIIZ attack -> not working yet (and cannot work in PHP4 + ZO) */
if (len != strlen(s)) {
return SUHOSIN_CODE_TYPE_0FILE;
}
/* disallow uploaded files */
if (SG(rfc1867_uploaded_files)) {
if (zend_hash_exists(SG(rfc1867_uploaded_files), (char *) s, e-s+1)) {
return SUHOSIN_CODE_TYPE_UPLOADED;
}
}
/* count number of directory traversals */
for (i=0; i < len-3; i++) {
if (s[i] == '.' && s[i+1] == '.' && (s[i+2] == '/' || s[i+2] == '\\')) {
count++;
i+=2;
}
}
if (SUHOSIN_G(executor_include_max_traversal) && SUHOSIN_G(executor_include_max_traversal)<=count) {
return SUHOSIN_CODE_TYPE_MANYDOTS;
}
SDEBUG("xxx %p %p",SUHOSIN_G(include_whitelist),SUHOSIN_G(include_blacklist));
/* no black or whitelist then disallow all */
if (SUHOSIN_G(include_whitelist)==NULL && SUHOSIN_G(include_blacklist)==NULL) {
/* disallow all URLs */
if (strstr(s, "://") != NULL || suhosin_strcasestr(s, "data:") != NULL) {
return SUHOSIN_CODE_TYPE_BADURL;
}
} else
/* whitelist is stronger than blacklist */
if (SUHOSIN_G(include_whitelist)) {
do {
isOk = 0;
h = strstr(s, "://");
h2 = suhosin_strcasestr(s, "data:");
h2 = h2 == NULL ? NULL : h2 + 4;
t = h = (h == NULL) ? h2 : ( (h2 == NULL) ? h : ( (h < h2) ? h : h2 ) );
if (h == NULL) break;
while (t > s && (isalnum(t[-1]) || t[-1]=='_' || t[-1]=='.')) {
t--;
}
tlen = e-t;
zend_hash_internal_pointer_reset(SUHOSIN_G(include_whitelist));
do {
int r = zend_hash_get_current_key_ex(SUHOSIN_G(include_whitelist), &index, &indexlen, &numindex, 0, NULL);
if (r==HASH_KEY_NON_EXISTANT) {
break;
}
if (r==HASH_KEY_IS_STRING) {
if (h-t <= indexlen-1 && tlen>=indexlen-1) {
if (strncasecmp(t, index, indexlen-1)==0) {
isOk = 1;
break;
}
}
}
zend_hash_move_forward(SUHOSIN_G(include_whitelist));
} while (1);
/* not found in whitelist */
if (!isOk) {
return SUHOSIN_CODE_TYPE_BADURL;
}
s = h + 1;
} while (1);
} else {
do {
int tlen;
h = strstr(s, "://");
h2 = suhosin_strcasestr(s, "data:");
h2 = h2 == NULL ? NULL : h2 + 4;
t = h = (h == NULL) ? h2 : ( (h2 == NULL) ? h : ( (h < h2) ? h : h2 ) );
if (h == NULL) break;
while (t > s && (isalnum(t[-1]) || t[-1]=='_' || t[-1]=='.')) {
t--;
}
tlen = e-t;
zend_hash_internal_pointer_reset(SUHOSIN_G(include_blacklist));
do {
int r = zend_hash_get_current_key_ex(SUHOSIN_G(include_blacklist), &index, &indexlen, &numindex, 0, NULL);
if (r==HASH_KEY_NON_EXISTANT) {
break;
}
if (r==HASH_KEY_IS_STRING) {
if (h-t <= indexlen-1 && tlen>=indexlen-1) {
if (strncasecmp(t, index, indexlen-1)==0) {
return SUHOSIN_CODE_TYPE_BLACKURL;
}
}
}
zend_hash_move_forward(SUHOSIN_G(include_blacklist));
} while (1);
s = h + 1;
} while (1);
}
/* disallow writable files */
if (!SUHOSIN_G(executor_include_allow_writable_files)) {
/* protection against *REMOTE* attacks, potential
race condition of access() is irrelevant */
if (access(s, W_OK) == 0) {
return SUHOSIN_CODE_TYPE_WRITABLE;
}
}
return SUHOSIN_CODE_TYPE_GOODFILE;
}
static int (*old_zend_stream_open)(const char *filename, zend_file_handle *fh TSRMLS_DC);
static int suhosin_zend_stream_open(const char *filename, zend_file_handle *fh TSRMLS_DC)
{
zend_execute_data *exd;
exd=EG(current_execute_data);
if (EG(in_execution) && (exd!=NULL) && (exd->opline != NULL) && (exd->opline->opcode == ZEND_INCLUDE_OR_EVAL)) {
int filetype = suhosin_check_filename((char *)filename, strlen(filename) TSRMLS_CC);
switch (filetype) {
case SUHOSIN_CODE_TYPE_LONGNAME:
suhosin_log(S_INCLUDE, "Include filename ('%s') is too long", filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_UPLOADED:
suhosin_log(S_INCLUDE, "Include filename is an uploaded file");
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_0FILE:
suhosin_log(S_INCLUDE, "Include filename contains an ASCIIZ character");
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_WRITABLE:
suhosin_log(S_INCLUDE, "Include filename ('%s') is writable by PHP process", filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_BLACKURL:
suhosin_log(S_INCLUDE, "Include filename ('%s') is a URL that is forbidden by the blacklist", filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_BADURL:
suhosin_log(S_INCLUDE, "Include filename ('%s') is a URL that is not allowed", filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_MANYDOTS:
suhosin_log(S_INCLUDE, "Include filename ('%s') contains too many '../'", filename);
suhosin_bailout(TSRMLS_C);
break;
}
}
return old_zend_stream_open(filename, fh TSRMLS_CC);
}
static int suhosin_detect_codetype(zend_op_array *op_array TSRMLS_DC)
{
char *s;
int r;
s = (char *)op_array->filename;
/* eval, assert, create_function, preg_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;
}
if (strstr(s, "regexp code") != NULL) {
return SUHOSIN_CODE_TYPE_REGEXP;
}
if (strstr(s, "mbregex replace") != NULL) {
return SUHOSIN_CODE_TYPE_MBREGEXP;
}
if (strstr(s, "assert code") != NULL) {
return SUHOSIN_CODE_TYPE_ASSERT;
}
if (strstr(s, "runtime-created function") != NULL) {
return SUHOSIN_CODE_TYPE_CFUNC;
}
if (strstr(s, "Command line code") != NULL) {
return SUHOSIN_CODE_TYPE_COMMANDLINE;
}
if (strstr(s, "Command line begin code") != NULL) {
return SUHOSIN_CODE_TYPE_COMMANDLINE;
}
if (strstr(s, "Command line run code") != NULL) {
return SUHOSIN_CODE_TYPE_COMMANDLINE;
}
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 {
r = suhosin_check_filename(s, strlen(s) TSRMLS_CC);
return r;
}
return SUHOSIN_CODE_TYPE_UNKNOWN;
}
/* {{{ void suhosin_execute_ex(zend_op_array *op_array TSRMLS_DC)
* This function provides a hook for execution */
#if PHP_VERSION_ID >= 50500
static void suhosin_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
{
zend_op_array *op_array = execute_data->op_array;
#else
static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dummy TSRMLS_DC)
{
#endif
zend_op_array *new_op_array;
int op_array_type, len;
char *fn;
zval cs;
zend_uint orig_code_type;
unsigned long *suhosin_flags = NULL;
/* log variable dropping statistics */
if (SUHOSIN_G(abort_request)) {
SUHOSIN_G(abort_request) = 0; /* we only want this to happen the first time */
if (SUHOSIN_G(att_request_variables)-SUHOSIN_G(cur_request_variables) > 0) {
suhosin_log(S_VARS, "dropped %u request variables - (%u in GET, %u in POST, %u in COOKIE)",
SUHOSIN_G(att_request_variables)-SUHOSIN_G(cur_request_variables),
SUHOSIN_G(att_get_vars)-SUHOSIN_G(cur_get_vars),
SUHOSIN_G(att_post_vars)-SUHOSIN_G(cur_post_vars),
SUHOSIN_G(att_cookie_vars)-SUHOSIN_G(cur_cookie_vars));
}
if (!SUHOSIN_G(simulation) && SUHOSIN_G(filter_action)) {
char *action = SUHOSIN_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 TSRMLS_CC);
efree(ctr.line);
} else {
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 TSRMLS_CC) == SUCCESS) {
if (!file_handle.opened_path) {
file_handle.opened_path = estrndup(action, strlen(action));
}
new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
if (new_op_array) {
EG(return_value_ptr_ptr) = &result;
EG(active_op_array) = new_op_array;
zend_execute(new_op_array TSRMLS_CC);
destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array);
if (!EG(exception))
{
if (EG(return_value_ptr_ptr)) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
EG(return_value_ptr_ptr) = NULL;
}
}
} else {
code = 500;
}
} else {
code = 500;
}
}
}
sapi_header_op(SAPI_HEADER_SET_STATUS, (void *)code TSRMLS_CC);
zend_bailout();
}
}
SDEBUG("%s %s", op_array->filename, op_array->function_name);
SUHOSIN_G(execution_depth)++;
if (SUHOSIN_G(max_execution_depth) && SUHOSIN_G(execution_depth) > SUHOSIN_G(max_execution_depth)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "maximum execution depth reached - script terminated");
suhosin_bailout(TSRMLS_C);
}
fn = (char *)op_array->filename;
len = strlen(fn);
orig_code_type = SUHOSIN_G(in_code_type);
if (op_array->type == ZEND_EVAL_CODE) {
SUHOSIN_G(in_code_type) = SUHOSIN_EVAL;
} else {
if (suhosin_zend_extension_entry.resource_number != -1) {
suhosin_flags = (unsigned long *) &op_array->reserved[suhosin_zend_extension_entry.resource_number];
SDEBUG("suhosin flags: %08lx", *suhosin_flags);
if (*suhosin_flags & SUHOSIN_FLAG_CREATED_BY_EVAL) {
SUHOSIN_G(in_code_type) = SUHOSIN_EVAL;
}
if (*suhosin_flags & SUHOSIN_FLAG_NOT_EVALED_CODE) {
goto not_evaled_code;
}
}
if (strstr(op_array->filename, "eval()'d code")) {
SUHOSIN_G(in_code_type) = SUHOSIN_EVAL;
} else {
if (suhosin_flags) {
*suhosin_flags |= SUHOSIN_FLAG_NOT_EVALED_CODE;
}
}
}
not_evaled_code:
SDEBUG("code type %u", SUHOSIN_G(in_code_type));
if (op_array->function_name) {
goto continue_execution;
}
/* if (SUHOSIN_G(deactivate)) {
goto continue_execution;
}
*/
op_array_type = suhosin_detect_codetype(op_array TSRMLS_CC);
switch (op_array_type) {
case SUHOSIN_CODE_TYPE_EVAL:
if (SUHOSIN_G(executor_disable_eval)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "use of eval is forbidden by configuration");
if (!SUHOSIN_G(simulation)) {
zend_error(E_ERROR, "SUHOSIN - Use of eval is forbidden by configuration");
}
}
break;
case SUHOSIN_CODE_TYPE_REGEXP:
if (SUHOSIN_G(executor_disable_emod)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "use of preg_replace() with /e modifier is forbidden by configuration");
if (!SUHOSIN_G(simulation)) {
zend_error(E_ERROR, "SUHOSIN - Use of preg_replace() with /e modifier is forbidden by configuration");
}
}
break;
case SUHOSIN_CODE_TYPE_MBREGEXP:
/* XXX TODO: Do we want to disallow this, too? */
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 ('%s') is too long", op_array->filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_MANYDOTS:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename ('%s') contains too many '../'", op_array->filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_UPLOADED:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename is an uploaded file");
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_0FILE:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename contains an ASCIIZ character");
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_WRITABLE:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename ('%s') is writable by PHP process", op_array->filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_BLACKURL:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename ('%s') is a URL that is forbidden by the blacklist", op_array->filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_BADURL:
suhosin_log(S_INCLUDE|S_GETCALLER, "Include filename ('%s') is a URL that is not allowed", op_array->filename);
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_BADFILE:
cs.type = IS_STRING;
#define DIE_WITH_MSG "die('disallowed_file'.chr(10).chr(10));"
cs.value.str.val = estrndup(DIE_WITH_MSG, sizeof(DIE_WITH_MSG)-1);
cs.value.str.len = sizeof(DIE_WITH_MSG)-1;
new_op_array = compile_string(&cs, "suhosin internal code" TSRMLS_CC);
if (new_op_array) {
op_array = new_op_array;
goto continue_execution;
}
suhosin_bailout(TSRMLS_C);
break;
case SUHOSIN_CODE_TYPE_COMMANDLINE:
case SUHOSIN_CODE_TYPE_SUHOSIN:
case SUHOSIN_CODE_TYPE_UNKNOWN:
case SUHOSIN_CODE_TYPE_GOODFILE:
goto continue_execution;
}
continue_execution:
#if PHP_VERSION_ID >= 50500
old_execute_ex (execute_data TSRMLS_CC);
#else
if (zo) {
old_execute_ZO (op_array, dummy TSRMLS_CC);
} else {
old_execute (op_array TSRMLS_CC);
}
#endif
/* nothing to do */
SUHOSIN_G(in_code_type) = orig_code_type;
SUHOSIN_G(execution_depth)--;
}
/* }}} */
#if PHP_VERSION_ID < 50500
/* {{{ void suhosin_execute(zend_op_array *op_array TSRMLS_DC)
* This function provides a hook for execution */
static void suhosin_execute(zend_op_array *op_array TSRMLS_DC)
{
suhosin_execute_ex(op_array, 0, 0 TSRMLS_CC);
}
/* {{{ void suhosin_execute(zend_op_array *op_array, long dummy TSRMLS_DC)
* This function provides a hook for execution */
static void suhosin_execute_ZO(zend_op_array *op_array, long dummy TSRMLS_DC)
{
suhosin_execute_ex(op_array, 1, dummy TSRMLS_CC);
}
/* }}} */
#endif
#if PHP_VERSION_ID >= 50500
#define IH_HANDLER_PARAMS_REST int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
#define IH_HANDLER_PARAMS internal_function_handler *ih, IH_HANDLER_PARAMS_REST
#define IH_HANDLER_PARAM_PASSTHRU ih, ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
#else
#define IH_HANDLER_PARAMS_REST zend_execute_data *execute_data_ptr, int return_value_used, int ht, zval *return_value TSRMLS_DC
#define IH_HANDLER_PARAMS internal_function_handler *ih, IH_HANDLER_PARAMS_REST
#define IH_HANDLER_PARAM_PASSTHRU ih, execute_data_ptr, return_value_used, ht, return_value TSRMLS_CC
#endif
HashTable ihandler_table;
typedef struct _internal_function_handler {
char *name;
int (*handler)(struct _internal_function_handler *ih, IH_HANDLER_PARAMS_REST);
void *arg1;
void *arg2;
void *arg3;
} internal_function_handler;
int ih_preg_replace(IH_HANDLER_PARAMS)
{
zval **regex,
**replace,
**subject,
**limit, **zcount;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|ZZ", ®ex, &replace, &subject, &limit, &zcount) == FAILURE) {
return (1);
}
if (Z_TYPE_PP(regex) == IS_ARRAY) {
zval **regex_entry;
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(regex));
/* For each entry in the regex array, get the entry */
while (zend_hash_get_current_data(Z_ARRVAL_PP(regex), (void **)®ex_entry) == SUCCESS) {
if (Z_TYPE_PP(regex_entry) == IS_STRING) {
if (strlen(Z_STRVAL_PP(regex_entry)) != Z_STRLEN_PP(regex_entry)) {
suhosin_log(S_EXECUTOR, "string termination attack on first preg_replace parameter detected");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
}
zend_hash_move_forward(Z_ARRVAL_PP(regex));
}
} else if (Z_TYPE_PP(regex) == IS_STRING) {
if (strlen(Z_STRVAL_PP(regex)) != Z_STRLEN_PP(regex)) {
suhosin_log(S_EXECUTOR, "string termination attack on first preg_replace parameter detected");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
}
return (0);
}
int ih_symlink(IH_HANDLER_PARAMS)
{
if (SUHOSIN_G(executor_allow_symlink)) {
return (0);
}
if (PG(open_basedir) && PG(open_basedir)[0]) {
suhosin_log(S_EXECUTOR, "symlink called during open_basedir");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
return (0);
}
int ih_mail(IH_HANDLER_PARAMS)
{
char *to=NULL, *message=NULL, *headers=NULL;
char *subject=NULL, *extra_cmd=NULL;
char *tmp;
int to_len, message_len, headers_len;
int subject_len, extra_cmd_len;
if (SUHOSIN_G(mailprotect) == 0) {
return (0);
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|ss",
&to, &to_len,
&subject, &subject_len,
&message, &message_len,
&headers, &headers_len,
&extra_cmd, &extra_cmd_len
) == FAILURE) {
RETVAL_FALSE;
return (1);
}
if (headers_len > 0 && headers &&
(strstr(headers, "\n\n") || strstr(headers, "\n\r\n") /* double newline */
|| *headers == '\n' || (headers[0] == '\r' && headers[1] == '\n') /* starts with newline */
)) {
suhosin_log(S_MAIL, "mail() - double newline in headers, possible injection, mail dropped");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
/* check for spam attempts with buggy webforms */
if (to_len > 0 && to) {
do {
if ((tmp = strchr(to, '\n')) == NULL)
tmp = strchr(to, '\r');
if (tmp == NULL) break;
to = tmp + 1;
if (!isspace(*to)) break;
} while (1);
if (tmp != NULL) {
suhosin_log(S_MAIL, "mail() - newline in To header, possible injection, mail dropped");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
}
if (subject_len > 0 && subject) {
do {
if ((tmp = strchr(subject, '\n')) == NULL)
tmp = strchr(subject, '\r');
if (tmp == NULL) break;
subject = tmp + 1;
if (!isspace(*subject)) break;
} while (1);
if (tmp != NULL) {
suhosin_log(S_MAIL, "mail() - newline in Subject header, possible injection, mail dropped");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
}
if (SUHOSIN_G(mailprotect) > 1) {
/* search for to, cc or bcc headers */
if (headers_len > 0 && headers != NULL) {
if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || suhosin_strcasestr(headers, "\nto:")) {
suhosin_log(S_MAIL, "mail() - To: headers aren't allowed in the headers parameter.");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
if (strncasecmp(headers, "cc:", sizeof("cc:") - 1) == 0 || suhosin_strcasestr(headers, "\ncc:")) {
suhosin_log(S_MAIL, "mail() - CC: headers aren't allowed in the headers parameter.");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
if (strncasecmp(headers, "bcc:", sizeof("bcc:") - 1) == 0 || suhosin_strcasestr(headers, "\nbcc:")) {
suhosin_log(S_MAIL, "mail() - BCC: headers aren't allowed in the headers parameter.");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
}
}
return (0);
}
#define SQLSTATE_SQL 0
#define SQLSTATE_IDENTIFIER 1
#define SQLSTATE_STRING 2
#define SQLSTATE_COMMENT 3
#define SQLSTATE_MLCOMMENT 4
int ih_querycheck(IH_HANDLER_PARAMS)
{
void **p = zend_vm_stack_top(TSRMLS_C) - 1;
unsigned long arg_count;
zval **arg;
char *query, *s, *e;
zval *backup;
int len;
char quote;
int state = SQLSTATE_SQL;
int cnt_union = 0, cnt_select = 0, cnt_comment = 0, cnt_opencomment = 0;
int mysql_extension = 0;
SDEBUG("function: %s", ih->name);
arg_count = (unsigned long) *p;
if (ht < (long) ih->arg1) {
return (0);
}
if ((long) ih->arg2) {
mysql_extension = 1;
}
arg = (zval **) p - (arg_count - (long) ih->arg1 + 1); /* count from 0 */
backup = *arg;
if (Z_TYPE_P(backup) != IS_STRING) {
return (0);
}
len = Z_STRLEN_P(backup);
query = Z_STRVAL_P(backup);
SDEBUG("SQL |%s|", query);
s = query;
e = s+len;
while (s < e) {
switch (state)
{
case SQLSTATE_SQL:
switch (s[0])
{
case '`':
state = SQLSTATE_IDENTIFIER;
quote = '`';
break;
case '\'':
case '"':
state = SQLSTATE_STRING;
quote = *s;
break;
case '/':
if (s[1]=='*') {
if (mysql_extension == 1 && s[2] == '!') {
s += 2;
break;
}
s++;
state = SQLSTATE_MLCOMMENT;
cnt_comment++;
}
break;
case '-':
if (s[1]=='-') {
s++;
state = SQLSTATE_COMMENT;
cnt_comment++;
}
break;
case '#':
state = SQLSTATE_COMMENT;
cnt_comment++;
break;
case 'u':
case 'U':
if (strncasecmp("union", s, 5)==0) {
s += 4;
cnt_union++;
}
break;
case 's':
case 'S':
if (strncasecmp("select", s, 6)==0) {
s += 5;
cnt_select++;
}
break;
}
break;
case SQLSTATE_STRING:
case SQLSTATE_IDENTIFIER:
if (s[0] == quote) {
if (s[1] == quote) {
s++;
} else {
state = SQLSTATE_SQL;
}
}
if (s[0] == '\\') {
s++;
}
break;
case SQLSTATE_COMMENT:
while (s[0] && s[0] != '\n') {
s++;
}
state = SQLSTATE_SQL;
break;
case SQLSTATE_MLCOMMENT:
while (s[0] && (s[0] != '*' || s[1] != '/')) {
s++;
}
if (s[0]) {
state = SQLSTATE_SQL;
}
break;
}
s++;
}
if (state == SQLSTATE_MLCOMMENT) {
cnt_opencomment = 1;
}
if (cnt_opencomment && SUHOSIN_G(sql_opencomment)>0) {
suhosin_log(S_SQL, "Open comment in SQL query: '%*s'", len, query);
if (SUHOSIN_G(sql_opencomment)>1) {
suhosin_bailout(TSRMLS_C);
}
}
if (cnt_comment && SUHOSIN_G(sql_comment)>0) {
suhosin_log(S_SQL, "Comment in SQL query: '%*s'", len, query);
if (SUHOSIN_G(sql_comment)>1) {
suhosin_bailout(TSRMLS_C);
}
}
if (cnt_union && SUHOSIN_G(sql_union)>0) {
suhosin_log(S_SQL, "UNION in SQL query: '%*s'", len, query);
if (SUHOSIN_G(sql_union)>1) {
suhosin_bailout(TSRMLS_C);
}
}
if (cnt_select>1 && SUHOSIN_G(sql_mselect)>0) {
suhosin_log(S_SQL, "Multiple SELECT in SQL query: '%*s'", len, query);
if (SUHOSIN_G(sql_mselect)>1) {
suhosin_bailout(TSRMLS_C);
}
}
return (0);
}
int ih_fixusername(IH_HANDLER_PARAMS)
{
void **p = zend_vm_stack_top(TSRMLS_C) - 1;
unsigned long arg_count;
zval **arg;
char *prefix, *postfix, *user, *user_match, *cp;
zval *backup, *my_user;
int prefix_len, postfix_len, len;
SDEBUG("function (fixusername): %s", ih->name);
prefix = SUHOSIN_G(sql_user_prefix);
postfix = SUHOSIN_G(sql_user_postfix);
user_match = SUHOSIN_G(sql_user_match);
arg_count = (unsigned long) *p;
if (ht < (long) ih->arg1) {
return (0);
}
arg = (zval **) p - (arg_count - (long) ih->arg1 + 1); /* count from 0 */
backup = *arg;
if (Z_TYPE_P(backup) != IS_STRING) {
user = "";
len = 0;
} else {
len = Z_STRLEN_P(backup);
user = Z_STRVAL_P(backup);
}
cp = user;
while (cp < user+len) {
if (*cp < 32) {
suhosin_log(S_SQL, "SQL username contains invalid characters");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
break;
}
cp++;
}
if ((prefix != NULL && prefix[0]) || (postfix != NULL && postfix[0])) {
if (prefix == NULL) {
prefix = "";
}
if (postfix == NULL) {
postfix = "";
}
prefix_len = strlen(prefix);
postfix_len = strlen(postfix);
MAKE_STD_ZVAL(my_user);
my_user->type = IS_STRING;
my_user->value.str.len = spprintf(&my_user->value.str.val, 0, "%s%s%s", prefix, user, postfix);
/* XXX: memory_leak? */
*arg = my_user;
len = Z_STRLEN_P(my_user);
user = Z_STRVAL_P(my_user);
}
if (user_match && user_match[0]) {
#ifdef HAVE_FNMATCH
if (fnmatch(user_match, user, 0) != 0) {
suhosin_log(S_SQL, "SQL username ('%s') does not match suhosin.sql.user_match ('%s')", user, user_match);
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
}
#else
#warning no support for fnmatch() - setting suhosin.sql.user_match will always fail.
suhosin_log(S_SQL, "suhosin.sql.user_match specified, but system does not support fnmatch()");
if (!SUHOSIN_G(simulation)) {
RETVAL_FALSE;
return (1);
}
#endif
}
SDEBUG("function: %s - user: %s", ih->name, user);
return (0);
}
static int ih_function_exists(IH_HANDLER_PARAMS)
{
char *name;
int name_len;
zend_function *func;
char *lcname;
zend_bool retval;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
return 1;
}
if (name_len <= 0) {
RETVAL_BOOL(0);
return 1;
}
lcname = zend_str_tolower_dup(name, name_len);
/* Ignore leading "\" */
name = lcname;
if (lcname[0] == '\\') {
name = &lcname[1];
name_len--;
}
retval = (zend_hash_find(EG(function_table), name, name_len+1, (void **)&func) == SUCCESS);
/*
* A bit of a hack, but not a bad one: we see if the handler of the function
* is actually one that displays "function is disabled" message.
*/
if (retval && func->type == ZEND_INTERNAL_FUNCTION &&
func->internal_function.handler == zif_display_disabled_function) {
retval = 0;
goto ret;
}
/* Now check if function is forbidden by Suhosin */
if (SUHOSIN_G(in_code_type) == SUHOSIN_EVAL) {
if (SUHOSIN_G(eval_whitelist) != NULL) {
if (!zend_hash_exists(SUHOSIN_G(eval_whitelist), name, name_len+1)) {
retval = 0;
goto ret;
}
} else if (SUHOSIN_G(eval_blacklist) != NULL) {
if (zend_hash_exists(SUHOSIN_G(eval_blacklist), name, name_len+1)) {
retval = 0;
goto ret;
}
}
}
if (SUHOSIN_G(func_whitelist) != NULL) {
if (!zend_hash_exists(SUHOSIN_G(func_whitelist), name, name_len+1)) {
retval = 0;
goto ret;
}
} else if (SUHOSIN_G(func_blacklist) != NULL) {
if (zend_hash_exists(SUHOSIN_G(func_blacklist), name, name_len+1)) {
retval = 0;
goto ret;
}
}
ret:
efree(lcname);
RETVAL_BOOL(retval);
return 1;
}
/* MT RAND FUNCTIONS */
/*
The following php_mt_...() functions are based on a C++ class MTRand by
Richard J. Wagner. For more information see the web page at
http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html
Mersenne Twister random number generator -- a C++ class MTRand
Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com
The Mersenne Twister is an algorithm for generating random numbers. It
was designed with consideration of the flaws in various other generators.
The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
are far greater. The generator is also fast; it avoids multiplication and
division, and it benefits from caches and pipelines. For more information
see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
Reference
M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
Copyright (C) 2000 - 2003, Richard J. Wagner
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
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
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The original code included the following notice:
When you use this, send an email to: matumoto@math.keio.ac.jp
with an appropriate reference to your work.
It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu
when you write.
*/
#define N 624 /* length of state vector */
#define M (397) /* a period parameter */
#define hiBit(u) ((u) & 0x80000000U) /* mask all but highest bit of u */
#define loBit(u) ((u) & 0x00000001U) /* mask all but lowest bit of u */
#define loBits(u) ((u) & 0x7FFFFFFFU) /* mask the highest bit of u */
#define mixBits(u, v) (hiBit(u)|loBits(v)) /* move hi bit of u to hi bit of v */
#define twist(m,u,v) (m ^ (mixBits(u,v)>>1) ^ ((php_uint32)(-(php_int32)(loBit(v))) & 0x9908b0dfU))
/* {{{ php_mt_initialize
*/
static inline void suhosin_mt_initialize(php_uint32 seed, php_uint32 *state)
{
/* Initialize generator state with seed
See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
In previous versions, most significant bits (MSBs) of the seed affect
only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. */
register php_uint32 *s = state;
register php_uint32 *r = state;
register int i = 1;
*s++ = seed & 0xffffffffU;
for( ; i < N; ++i ) {
*s++ = ( 1812433253U * ( *r ^ (*r >> 30) ) + i ) & 0xffffffffU;
r++;
}
}
/* }}} */
static inline void suhosin_mt_init_by_array(php_uint32 *key, int keylen, php_uint32 *state)
{
int i, j, k;
suhosin_mt_initialize(19650218U, state);
i = 1; j = 0;
k = (N > keylen ? N : keylen);
for (; k; k--) {
state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525U)) + key[j] + j;
i++; j = (j+1) % keylen;
if (i >= N) { state[0] = state[N-1]; i=1; }
}
for (k=N-1; k; k--) {
state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941U)) - i;
i++;
if (i >= N) { state[0] = state[N-1]; i=1; }
}
state[0] = 0x80000000U;
}
/* }}} */
/* {{{ suhosin_mt_reload
*/
static inline void suhosin_mt_reload(php_uint32 *state, php_uint32 **next, int *left)
{
/* Generate N new values in state
Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) */
register php_uint32 *p = state;
register int i;
for (i = N - M; i--; ++p)
*p = twist(p[M], p[0], p[1]);
for (i = M; --i; ++p)
*p = twist(p[M-N], p[0], p[1]);
*p = twist(p[M-N], p[0], state[0]);
*left = N;
*next = state;
}
/* }}} */
/* {{{ suhosin_mt_srand
*/
static void suhosin_mt_srand(php_uint32 seed TSRMLS_DC)
{
/* Seed the generator with a simple uint32 */
suhosin_mt_initialize(seed, SUHOSIN_G(mt_state));
suhosin_mt_reload(SUHOSIN_G(mt_state), &SUHOSIN_G(mt_next), &SUHOSIN_G(mt_left));
/* Seed only once */
SUHOSIN_G(mt_is_seeded) = 1;
}
/* }}} */
/* {{{ suhosin_mt_rand
*/
static php_uint32 suhosin_mt_rand(TSRMLS_D)
{
/* Pull a 32-bit integer from the generator state
Every other access function simply transforms the numbers extracted here */
register php_uint32 s1;
if (SUHOSIN_G(mt_left) == 0) {
suhosin_mt_reload(SUHOSIN_G(mt_state), &SUHOSIN_G(mt_next), &SUHOSIN_G(mt_left));
}
--SUHOSIN_G(mt_left);
s1 = *SUHOSIN_G(mt_next)++;
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9d2c5680U;
s1 ^= (s1 << 15) & 0xefc60000U;
return ( s1 ^ (s1 >> 18) );
}
/* }}} */
/* {{{ suhosin_gen_entropy
*/
static void suhosin_gen_entropy(php_uint32 *entropybuf TSRMLS_DC)
{
php_uint32 seedbuf[20];
/* On a modern OS code, stack and heap base are randomized */
unsigned long code_value = (unsigned long)suhosin_gen_entropy;
unsigned long stack_value = (unsigned long)&code_value;
unsigned long heap_value = (unsigned long)SUHOSIN_G(r_state);
suhosin_SHA256_CTX context;
int fd;
code_value ^= code_value >> 32;
stack_value ^= stack_value >> 32;
heap_value ^= heap_value >> 32;
seedbuf[0] = code_value;
seedbuf[1] = stack_value;
seedbuf[2] = heap_value;
seedbuf[3] = time(0);
#ifdef PHP_WIN32
seedbuf[4] = GetCurrentProcessId();
#else
seedbuf[4] = getpid();
#endif
seedbuf[5] = (php_uint32) 0x7fffffff * php_combined_lcg(TSRMLS_C);
#ifndef PHP_WIN32
fd = VCWD_OPEN("/dev/urandom", O_RDONLY);
if (fd >= 0) {
/* ignore error case - if urandom doesn't give us any/enough random bytes */
read(fd, &seedbuf[6], 8 * sizeof(php_uint32));
close(fd);
}
#else
/* we have to live with the possibility that this call fails */
php_win32_get_random_bytes((unsigned char*)&seedbuf[6], 8 * sizeof(php_uint32));
#endif
suhosin_SHA256Init(&context);
/* to our friends from Debian: yes this will add unitialized stack values to the entropy DO NOT REMOVE */
suhosin_SHA256Update(&context, (void *) seedbuf, sizeof(seedbuf));
if (SUHOSIN_G(seedingkey) != NULL && *SUHOSIN_G(seedingkey) != 0) {
suhosin_SHA256Update(&context, (unsigned char*)SUHOSIN_G(seedingkey), strlen(SUHOSIN_G(seedingkey)));
}
suhosin_SHA256Final((void *)entropybuf, &context);
}
/* }}} */
/* {{{ suhosin_srand_auto
*/
static void suhosin_srand_auto(TSRMLS_D)
{
php_uint32 seed[8];
suhosin_gen_entropy(&seed[0] TSRMLS_CC);
suhosin_mt_init_by_array(seed, 8, SUHOSIN_G(r_state));
suhosin_mt_reload(SUHOSIN_G(r_state), &SUHOSIN_G(r_next), &SUHOSIN_G(r_left));
/* Seed only once */
SUHOSIN_G(r_is_seeded) = 1;
}
/* }}} */
/* {{{ suhosin_mt_srand_auto
*/
static void suhosin_mt_srand_auto(TSRMLS_D)
{
php_uint32 seed[8];
suhosin_gen_entropy(&seed[0] TSRMLS_CC);
suhosin_mt_init_by_array(seed, 8, SUHOSIN_G(mt_state));
suhosin_mt_reload(SUHOSIN_G(mt_state), &SUHOSIN_G(mt_next), &SUHOSIN_G(mt_left));
/* Seed only once */
SUHOSIN_G(mt_is_seeded) = 1;
}
/* }}} */
/* {{{ suhosin_srand
*/
static void suhosin_srand(php_uint32 seed TSRMLS_DC)
{
/* Seed the generator with a simple uint32 */
suhosin_mt_initialize(seed+0x12345, SUHOSIN_G(r_state));
suhosin_mt_reload(SUHOSIN_G(r_state), &SUHOSIN_G(r_next), &SUHOSIN_G(r_left));
/* Seed only once */
SUHOSIN_G(r_is_seeded) = 1;
}
/* }}} */
/* {{{ suhosin_mt_rand
*/
static php_uint32 suhosin_rand(TSRMLS_D)
{
/* Pull a 32-bit integer from the generator state
Every other access function simply transforms the numbers extracted here */
register php_uint32 s1;
if (SUHOSIN_G(r_left) == 0) {
suhosin_mt_reload(SUHOSIN_G(r_state), &SUHOSIN_G(r_next), &SUHOSIN_G(r_left));
}
--SUHOSIN_G(r_left);
s1 = *SUHOSIN_G(r_next)++;
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9d2c5680U;
s1 ^= (s1 << 15) & 0xefc60000U;
return ( s1 ^ (s1 >> 18) );
}
/* }}} */
static int ih_srand(IH_HANDLER_PARAMS)
{
int argc = ZEND_NUM_ARGS();
long seed;
if (SUHOSIN_G(srand_ignore)) {
SUHOSIN_G(r_is_seeded) = 0;
return 1;
}
if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE) {
return 1;
}
if (argc) {
suhosin_srand(seed TSRMLS_CC);
} else {
suhosin_srand_auto(TSRMLS_C);
}
return (1);
}
static int ih_mt_srand(IH_HANDLER_PARAMS)
{
int argc = ZEND_NUM_ARGS();
long seed;
if (SUHOSIN_G(mt_srand_ignore)) {
SUHOSIN_G(mt_is_seeded) = 0;
return 1;
}
if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE) {
return 1;
}
if (argc) {
suhosin_mt_srand(seed TSRMLS_CC);
} else {
suhosin_mt_srand_auto(TSRMLS_C);
}
return 1;
}
static int ih_mt_rand(IH_HANDLER_PARAMS)
{
int argc = ZEND_NUM_ARGS();
long min;
long max;
long number;
if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) {
return (1);
}
if (!SUHOSIN_G(mt_is_seeded)) {
suhosin_mt_srand_auto(TSRMLS_C);
}
number = (long) (suhosin_mt_rand(TSRMLS_C) >> 1);
if (argc == 2) {
RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
}
RETVAL_LONG(number);
return (1);
}
static int ih_rand(IH_HANDLER_PARAMS)
{
int argc = ZEND_NUM_ARGS();
long min;
long max;
long number;
if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) {
return (1);
}
if (!SUHOSIN_G(r_is_seeded)) {
suhosin_srand_auto(TSRMLS_C);
}
number = (long) (suhosin_rand(TSRMLS_C) >> 1);
if (argc == 2) {
RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
}
RETVAL_LONG(number);
return (1);
}
static int ih_getrandmax(IH_HANDLER_PARAMS)
{
if (zend_parse_parameters_none() == FAILURE) {
return (1);
}
RETVAL_LONG(PHP_MT_RAND_MAX);
return (1);
}
internal_function_handler ihandlers[] = {
{ "preg_replace", ih_preg_replace, NULL, NULL, NULL },
{ "mail", ih_mail, NULL, NULL, NULL },
{ "symlink", ih_symlink, NULL, NULL, NULL },
{ "srand", ih_srand, NULL, NULL, NULL },
{ "mt_srand", ih_mt_srand, NULL, NULL, NULL },
{ "rand", ih_rand, NULL, NULL, NULL },
{ "mt_rand", ih_mt_rand, NULL, NULL, NULL },
{ "getrandmax", ih_getrandmax, NULL, NULL, NULL },
{ "mt_getrandmax", ih_getrandmax, NULL, NULL, NULL },
{ "function_exists", ih_function_exists, NULL, NULL, NULL },
/* Mysqli */
{ "mysqli::mysqli", ih_fixusername, (void *)2, NULL, NULL },
{ "mysqli_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "mysqli::real_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "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 },
{ "mysqli_multi_query", ih_querycheck, (void *)2, (void *)1, NULL },
{ "mysqli::prepare", ih_querycheck, (void *)1, (void *)1, NULL },
{ "mysqli_prepare", ih_querycheck, (void *)2, (void *)1, NULL },
{ "mysqli::real_query", ih_querycheck, (void *)1, (void *)1, NULL },
{ "mysqli_real_query", ih_querycheck, (void *)2, (void *)1, NULL },
{ "mysqli::send_query", ih_querycheck, (void *)1, (void *)1, NULL },
{ "mysqli_send_query", ih_querycheck, (void *)2, (void *)1, NULL },
// removed in PHP 5.3
{ "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 SUHOSIN_EXPERIMENTAL
/* MaxDB */
{ "maxdb::maxdb", ih_fixusername, (void *)2, NULL, NULL },
{ "maxdb_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "maxdb::real_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "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 },
{ "maxdb::query", ih_querycheck, (void *)1, NULL, NULL },
{ "maxdb_query", ih_querycheck, (void *)2, NULL, NULL },
{ "maxdb::real_query", ih_querycheck, (void *)1, NULL, NULL },
{ "maxdb_real_query", ih_querycheck, (void *)2, NULL, NULL },
{ "maxdb::send_query", ih_querycheck, (void *)1, NULL, NULL },
{ "maxdb_send_query", ih_querycheck, (void *)2, NULL, NULL },
{ "maxdb::prepare", ih_querycheck, (void *)1, NULL, NULL },
{ "maxdb_prepare", ih_querycheck, (void *)2, NULL, NULL },
/* PDO */
/* note: mysql conditional comments not supported here */
{ "pdo::__construct", ih_fixusername, (void *)2, NULL, NULL }, /* note: username may come from dsn (param 1) */
{ "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 },
{ "ocinlogon", ih_fixusername, (void *)1, NULL, NULL },
{ "oci_connect", ih_fixusername, (void *)1, NULL, NULL },
{ "oci_pconnect", ih_fixusername, (void *)1, NULL, NULL },
{ "oci_new_connect", ih_fixusername, (void *)1, NULL, NULL },
/* FrontBase */
{ "fbsql_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "fbsql_pconnect", ih_fixusername, (void *)2, NULL, NULL },
{ "fbsql_change_user", ih_fixusername, (void *)1, NULL, NULL },
{ "fbsql_username", ih_fixusername, (void *)2, NULL, NULL },
/* 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 },
{ "ibase_service_attach", ih_fixusername, (void *)2, NULL, NULL },
/* Microsoft SQL Server */
{ "mssql_connect", ih_fixusername, (void *)2, NULL, NULL },
{ "mssql_pconnect", ih_fixusername, (void *)2, NULL, NULL },
#endif
{ NULL, NULL, NULL, NULL, NULL }
};
#define FUNCTION_WARNING() zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C));
#define FUNCTION_SIMULATE_WARNING() zend_error(E_WARNING, "SIMULATION - %s() has been disabled for security reasons", get_active_function_name(TSRMLS_C));
/* {{{ void suhosin_execute_internal
* This function provides a hook for internal execution */
#if PHP_VERSION_ID >= 50500
#define EX_T(offset) (*EX_TMP_VAR(execute_data_ptr, offset))
static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC)
{
zval *return_value;
zval **return_value_ptr;
zval *this_ptr;
int ht;
if (fci) {
return_value = *fci->retval_ptr_ptr;
return_value_ptr = fci->retval_ptr_ptr;
this_ptr = fci->object_ptr;
ht = fci->param_count;
} else {
temp_variable *ret = &EX_T(execute_data_ptr->opline->result.var);
zend_function *fbc = execute_data_ptr->function_state.function;
return_value = ret->var.ptr;
return_value_ptr = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL;
this_ptr = execute_data_ptr->object;
ht = execute_data_ptr->opline->extended_value;
}
#else
static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC)
{
zval *return_value;
int ht = execute_data_ptr->opline->extended_value;
#endif
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);
memcpy(tmp, ce->name, ce->name_length);
memcpy(tmp+ce->name_length, "::", 2);
memcpy(tmp+ce->name_length+2, lcname, function_name_strlen);
lcname = tmp;
free_lcname = 1;
function_name_strlen += ce->name_length + 2;
lcname[function_name_strlen] = 0;
zend_str_tolower(lcname, function_name_strlen);
}
#if PHP_VERSION_ID < 50500
return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr;
#endif
SDEBUG("function: %s", lcname);
if (SUHOSIN_G(in_code_type) == SUHOSIN_EVAL) {
if (SUHOSIN_G(eval_whitelist) != NULL) {
if (!zend_hash_exists(SUHOSIN_G(eval_whitelist), lcname, function_name_strlen+1)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "function outside of eval whitelist called: %s()", lcname);
if (!SUHOSIN_G(simulation)) {
goto execute_internal_bailout;
} else {
FUNCTION_SIMULATE_WARNING()
}
}
} else if (SUHOSIN_G(eval_blacklist) != NULL) {
if (zend_hash_exists(SUHOSIN_G(eval_blacklist), lcname, function_name_strlen+1)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "function within eval blacklist called: %s()", lcname);
if (!SUHOSIN_G(simulation)) {
goto execute_internal_bailout;
} else {
FUNCTION_SIMULATE_WARNING()
}
}
}
}
if (SUHOSIN_G(func_whitelist) != NULL) {
if (!zend_hash_exists(SUHOSIN_G(func_whitelist), lcname, function_name_strlen+1)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "function outside of whitelist called: %s()", lcname);
if (!SUHOSIN_G(simulation)) {
goto execute_internal_bailout;
} else {
FUNCTION_SIMULATE_WARNING()
}
}
} else if (SUHOSIN_G(func_blacklist) != NULL) {
if (zend_hash_exists(SUHOSIN_G(func_blacklist), lcname, function_name_strlen+1)) {
suhosin_log(S_EXECUTOR|S_GETCALLER, "function within blacklist called: %s()", lcname);
if (!SUHOSIN_G(simulation)) {
goto execute_internal_bailout;
} else {
FUNCTION_SIMULATE_WARNING()
}
}
}
if (zend_hash_find(&ihandler_table, lcname, function_name_strlen+1, (void **)&ih) == SUCCESS) {
int retval = 0;
void *handler = ((zend_internal_function *) execute_data_ptr->function_state.function)->handler;
if (handler != ZEND_FN(display_disabled_function)) {
retval = ih->handler(IH_HANDLER_PARAM_PASSTHRU);
}
if (retval == 0) {
#if PHP_VERSION_ID >= 50500
old_execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC);
#else
old_execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
#endif
}
} else {
#if PHP_VERSION_ID >= 50500
old_execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC);
#else
old_execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
#endif
}
if (free_lcname == 1) {
efree(lcname);
}
return;
execute_internal_bailout:
if (free_lcname == 1) {
efree(lcname);
}
FUNCTION_WARNING()
suhosin_bailout(TSRMLS_C);
}
/* }}} */
/* {{{ int function_lookup(zend_extension *extension)
*/
static int function_lookup(zend_extension *extension)
{
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;
}
/* }}} */
/* {{{ void suhosin_hook_execute()
*/
void suhosin_hook_execute(TSRMLS_D)
{
internal_function_handler *ih;
#if PHP_VERSION_ID >= 50500
old_execute_ex = zend_execute_ex;
zend_execute_ex = suhosin_execute_ex;
#else
old_execute = zend_execute;
zend_execute = suhosin_execute;
#endif
/* old_compile_file = zend_compile_file;
zend_compile_file = suhosin_compile_file; */
#if ZO_COMPATIBILITY_HACK_TEMPORARY_DISABLED
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) {
zend_llist_apply(&zend_extensions, (llist_apply_func_t)function_lookup TSRMLS_CC);
}
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);
ih = &ihandlers[0];
while (ih->name) {
zend_hash_add(&ihandler_table, ih->name, strlen(ih->name)+1, ih, sizeof(internal_function_handler), NULL);
ih++;
}
/* Add additional protection layer, that SHOULD
catch ZEND_INCLUDE_OR_EVAL *before* the engine tries
to execute */
old_zend_stream_open = zend_stream_open_function;
zend_stream_open_function = suhosin_zend_stream_open;
}
/* }}} */
/* {{{ void suhosin_unhook_execute()
*/
void suhosin_unhook_execute()
{
#if ZO_COMPATIBILITY_HACK_TEMPORARY_DISABLED
if (zo_set_oe_ex) {
zo_set_oe_ex(old_execute_ZO);
}
#endif
#if PHP_VERSION_ID >= 50500
zend_execute_ex = old_execute_ex;
#else
zend_execute = old_execute;
#endif
/* zend_compile_file = old_compile_file; */
if (old_execute_internal == execute_internal) {
old_execute_internal = NULL;
}
zend_execute_internal = old_execute_internal;
zend_hash_clean(&ihandler_table);
/* remove zend_open protection */
zend_stream_open_function = old_zend_stream_open;
}
/* }}} */
/*
* 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
*/
================================================
FILE: header.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/*
$Id: header.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/url.h"
#include "php_suhosin.h"
#include "SAPI.h"
#include "php_variables.h"
static int (*orig_header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC) = NULL;
char *suhosin_encrypt_single_cookie(char *name, int name_len, char *value, int value_len, char *key TSRMLS_DC)
{
char *buf, *buf2, *d, *d_url;
int l;
buf = estrndup(name, name_len);
name_len = php_url_decode(buf, name_len);
normalize_varname(buf);
name_len = strlen(buf);
if (SUHOSIN_G(cookie_plainlist)) {
if (zend_hash_exists(SUHOSIN_G(cookie_plainlist), buf, name_len+1)) {
encrypt_return_plain:
efree(buf);
return estrndup(value, value_len);
}
} else if (SUHOSIN_G(cookie_cryptlist)) {
if (!zend_hash_exists(SUHOSIN_G(cookie_cryptlist), buf, name_len+1)) {
goto encrypt_return_plain;
}
}
buf2 = estrndup(value, value_len);
value_len = php_url_decode(buf2, value_len);
d = suhosin_encrypt_string(buf2, value_len, buf, name_len, key TSRMLS_CC);
d_url = php_url_encode(d, strlen(d), &l);
efree(d);
efree(buf);
efree(buf2);
return d_url;
}
char *suhosin_decrypt_single_cookie(char *name, int name_len, char *value, int value_len, char *key, char **where TSRMLS_DC)
{
int o_name_len = name_len;
char *buf, *buf2, *d, *d_url;
int l;
buf = estrndup(name, name_len);
name_len = php_url_decode(buf, name_len);
normalize_varname(buf);
name_len = strlen(buf);
if (SUHOSIN_G(cookie_plainlist)) {
if (zend_hash_exists(SUHOSIN_G(cookie_plainlist), buf, name_len+1)) {
decrypt_return_plain:
efree(buf);
memcpy(*where, name, o_name_len);
*where += o_name_len;
**where = '='; *where +=1;
memcpy(*where, value, value_len);
*where += value_len;
return *where;
}
} else if (SUHOSIN_G(cookie_cryptlist)) {
if (!zend_hash_exists(SUHOSIN_G(cookie_cryptlist), buf, name_len+1)) {
goto decrypt_return_plain;
}
}
buf2 = estrndup(value, value_len);
value_len = php_url_decode(buf2, value_len);
d = suhosin_decrypt_string(buf2, value_len, buf, name_len, key, &l, SUHOSIN_G(cookie_checkraddr) TSRMLS_CC);
if (d == NULL) {
goto skip_cookie;
}
d_url = php_url_encode(d, l, &l);
efree(d);
memcpy(*where, name, o_name_len);
*where += o_name_len;
**where = '=';*where += 1;
memcpy(*where, d_url, l);
*where += l;
efree(d_url);
skip_cookie:
efree(buf);
efree(buf2);
return *where;
}
/* {{{ suhosin_cookie_decryptor
*/
char *suhosin_cookie_decryptor(TSRMLS_D)
{
char *raw_cookie = SG(request_info).cookie_data;
char *decrypted, *ret, *var, *val, *tmp;
int j;
char cryptkey[33];
/*
if (...deactivated...) {
return estrdup(raw_cookie);
}
*/
suhosin_generate_key(SUHOSIN_G(cookie_cryptkey), SUHOSIN_G(cookie_cryptua), SUHOSIN_G(cookie_cryptdocroot), SUHOSIN_G(cookie_cryptraddr), (char *)&cryptkey TSRMLS_CC);
ret = decrypted = emalloc(strlen(raw_cookie)*4+1);
raw_cookie = estrdup(raw_cookie);
SUHOSIN_G(raw_cookie) = estrdup(raw_cookie);
j = 0; tmp = raw_cookie;
while (*tmp) {
char *d_url;int varlen;
while (*tmp == '\t' || *tmp == ' ') tmp++;
var = tmp;
while (*tmp && *tmp != ';' && *tmp != '=') tmp++;
varlen = tmp-var;
/*memcpy(decrypted, var, varlen);
decrypted += varlen;*/
if (*tmp == 0) break;
if (*tmp++ == ';') {
*decrypted++ = ';';
continue;
}
/**decrypted++ = '=';*/
val = tmp;
while (*tmp && *tmp != ';') tmp++;
d_url = suhosin_decrypt_single_cookie(var, varlen, val, tmp-val, (char *)&cryptkey, &decrypted TSRMLS_CC);
if (*tmp == ';') {
*decrypted++ = ';';
}
if (*tmp == 0) break;
tmp++;
}
*decrypted++ = 0;
ret = erealloc(ret, decrypted-ret);
SUHOSIN_G(decrypted_cookie) = ret;
efree(raw_cookie);
return ret;
}
/* }}} */
/* {{{ suhosin_header_handler
*/
int suhosin_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
{
int retval = SAPI_HEADER_ADD, i;
char *tmp;
if (op != SAPI_HEADER_ADD && op != SAPI_HEADER_REPLACE) {
goto suhosin_skip_header_handling;
}
if (sapi_header && sapi_header->header) {
tmp = sapi_header->header;
for (i=0; i<sapi_header->header_len; i++, tmp++) {
if (tmp[0] == 0) {
char *fname = (char *)get_active_function_name(TSRMLS_C);
if (!fname) {
fname = "unknown";
}
suhosin_log(S_MISC, "%s() - wanted to send a HTTP header with an ASCII NUL in it", fname);
if (!SUHOSIN_G(simulation)) {
sapi_header->header_len = i;
}
}
if (SUHOSIN_G(allow_multiheader)) {
continue;
} 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')))) {
char *fname = (char *)get_active_function_name(TSRMLS_C);
if (!fname) {
fname = "unknown";
}
suhosin_log(S_MISC, "%s() - wanted to send multiple HTTP headers at once", fname);
if (!SUHOSIN_G(simulation)) {
sapi_header->header_len = i;
tmp[0] = 0;
}
}
}
}
/* Handle a potential cookie */
if (SUHOSIN_G(cookie_encrypt) && (strncasecmp("Set-Cookie:", sapi_header->header, sizeof("Set-Cookie:")-1) == 0)) {
char *start, *end, *rend, *tmp;
char *name, *value;
int nlen, vlen, len, tlen;
char cryptkey[33];
suhosin_generate_key(SUHOSIN_G(cookie_cryptkey), SUHOSIN_G(cookie_cryptua), SUHOSIN_G(cookie_cryptdocroot), SUHOSIN_G(cookie_cryptraddr), (char *)&cryptkey TSRMLS_CC);
start = estrndup(sapi_header->header, sapi_header->header_len);
rend = end = start + sapi_header->header_len;
tmp = memchr(start, ';', end-start);
if (tmp != NULL) {
end = tmp;
}
tmp = start + sizeof("Set-Cookie:") - 1;
while (tmp < end && tmp[0]==' ') {
tmp++;
}
name = tmp;
nlen = end-name;
tmp = memchr(name, '=', nlen);
if (tmp == NULL) {
value = end;
} else {
value = tmp+1;
nlen = tmp-name;
}
vlen = end-value;
value = suhosin_encrypt_single_cookie(name, nlen, value, vlen, (char *)&cryptkey TSRMLS_CC);
vlen = strlen(value);
len = sizeof("Set-Cookie: ")-1 + nlen + 1 + vlen + rend-end;
tmp = emalloc(len + 1);
tlen = sprintf(tmp, "Set-Cookie: %.*s=%s", nlen,name, value);
memcpy(tmp + tlen, end, rend-end);
tmp[len] = 0;
efree(sapi_header->header);
efree(value);
efree(start);
sapi_header->header = tmp;
sapi_header->header_len = len;
}
suhosin_skip_header_handling:
/* If existing call the sapi header handler */
if (orig_header_handler) {
retval = orig_header_handler(sapi_header, op, sapi_headers TSRMLS_CC);
}
return retval;
}
/* }}} */
/* {{{ suhosin_hook_header_handler
*/
void suhosin_hook_header_handler()
{
if (orig_header_handler == NULL) {
orig_header_handler = sapi_module.header_handler;
sapi_module.header_handler = suhosin_header_handler;
}
}
/* }}} */
/* {{{ suhosin_unhook_header_handler
*/
void suhosin_unhook_header_handler()
{
sapi_module.header_handler = orig_header_handler;
orig_header_handler = NULL;
}
/* }}} */
/*
* 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
*/
================================================
FILE: ifilter.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/*
$Id: ifilter.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_suhosin.h"
#include "php_variables.h"
#include "ext/standard/php_var.h"
static void (*orig_register_server_variables)(zval *track_vars_array TSRMLS_DC) = NULL;
#if !HAVE_STRNLEN
static size_t strnlen(const char *s, size_t maxlen) {
char *r = memchr(s, '\0', maxlen);
return r ? r-s : maxlen;
}
#endif
size_t suhosin_strnspn(const char *input, size_t n, const char *accept)
{
size_t count = 0;
for (; *input != '\0' && count < n; input++, count++) {
if (strchr(accept, *input) == NULL)
break;
}
return count;
}
size_t suhosin_strncspn(const char *input, size_t n, const char *reject)
{
size_t count = 0;
for (; *input != '\0' && count < n; input++, count++) {
if (strchr(reject, *input) != NULL)
break;
}
return count;
}
/* {{{ normalize_varname
*/
void 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);
}
for (p=varname; *p && *p != '['; p++) {
switch(*p) {
case ' ':
case '.':
*p='_';
break;
}
}
/* find index */
index = strchr(varname, '[');
if (index) {
index++;
s=index;
} else {
return;
}
/* done? */
while (index) {
while (*index == ' ' || *index == '\r' || *index == '\n' || *index=='\t') {
index++;
}
indexend = strchr(index, ']');
indexend = indexend ? indexend + 1 : index + strlen(index);
if (s != index) {
memmove(s, index, strlen(index)+1);
s += indexend-index;
} else {
s = indexend;
}
if (*s == '[') {
s++;
index = s;
} else {
index = NULL;
}
}
*s++='\0';
}
/* }}} */
static unsigned char suhosin_hexchars[] = "0123456789ABCDEF";
static const char suhosin_is_dangerous_char[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* {{{ suhosin_server_encode
*/
static void suhosin_server_strip(HashTable *arr, char *key, int klen)
{
zval **tzval;
unsigned char *s, *t;
if (zend_hash_find(arr, key, klen, (void **) &tzval) == SUCCESS &&
Z_TYPE_PP(tzval) == IS_STRING) {
s = t = (unsigned char *)Z_STRVAL_PP(tzval);
for (; *t; t++) {
if (suhosin_is_dangerous_char[*t]) {
*t = '?';
}
}
Z_STRLEN_PP(tzval) = t-s;
}
}
/* }}} */
/* {{{ suhosin_server_encode
*/
static void suhosin_server_encode(HashTable *arr, char *key, int klen)
{
zval **tzval;
unsigned char *temp = NULL, *t, *newv, *n;
int extra = 0;
if (zend_hash_find(arr, key, klen, (void **) &tzval) == SUCCESS &&
Z_TYPE_PP(tzval) == IS_STRING) {
temp = (unsigned char *)Z_STRVAL_PP(tzval);
for (t = temp; *t; t++) {
if (suhosin_is_dangerous_char[*t]) {
extra += 2;
}
}
/* no extra bytes required */
if (extra == 0) {
return;
}
n = newv = emalloc(t - temp + 1 + extra);
t = temp;
for (t = temp; *t; t++, n++) {
if (suhosin_is_dangerous_char[*t]) {
*n++ = '%';
*n++ = suhosin_hexchars[*t >> 4];
*n = suhosin_hexchars[*t & 15];
} else {
*n = *t;
}
}
*n = 0;
/* XXX: we leak memory here, but only for the duration of the request */
Z_STRVAL_PP(tzval) = (char *)newv;
Z_STRLEN_PP(tzval) = n-newv;
}
}
/* }}} */
/* {{{ suhosin_register_server_variables
*/
void suhosin_register_server_variables(zval *track_vars_array TSRMLS_DC)
{
HashTable *svars;
int retval = 0, failure = 0;
orig_register_server_variables(track_vars_array TSRMLS_CC);
svars = Z_ARRVAL_P(track_vars_array);
if (!SUHOSIN_G(simulation)) {
retval = zend_hash_del(svars, "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"));
if (retval == SUCCESS) failure = 1;
retval = zend_hash_del(svars, "HTTP_RAW_POST_DATA", sizeof("HTTP_RAW_POST_DATA"));
if (retval == SUCCESS) failure = 1;
} else {
retval = zend_hash_exists(svars, "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"));
retval+= zend_hash_exists(svars, "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"));
retval+= zend_hash_exists(svars, "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"));
retval+= zend_hash_exists(svars, "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"));
retval+= zend_hash_exists(svars, "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"));
retval+= zend_hash_exists(svars, "HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"));
retval+= zend_hash_exists(svars, "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"));
retval+= zend_hash_exists(svars, "HTTP_RAW_POST_DATA", sizeof("HTTP_RAW_POST_DATA"));
if (retval > 0) failure = 1;
}
if (failure) {
suhosin_log(S_VARS, "Attacker tried to overwrite a superglobal through a HTTP header");
}
if (SUHOSIN_G(raw_cookie)) {
zval *z;
MAKE_STD_ZVAL(z);
ZVAL_STRING(z, SUHOSIN_G(raw_cookie), 1);
zend_hash_add(svars, "RAW_HTTP_COOKIE", sizeof("RAW_HTTP_COOKIE"), (void **)&z, sizeof(zval *), NULL);
}
if (SUHOSIN_G(decrypted_cookie)) {
zval *z;
MAKE_STD_ZVAL(z);
ZVAL_STRING(z, SUHOSIN_G(decrypted_cookie), 0);
zend_hash_update(svars, "HTTP_COOKIE", sizeof("HTTP_COOKIE"), (void **)&z, sizeof(zval *), NULL);
SUHOSIN_G(decrypted_cookie) = NULL;
}
if (SUHOSIN_G(server_encode)) {
/* suhosin_server_encode(svars, "argv", sizeof("argv")); */
suhosin_server_encode(svars, "REQUEST_URI", sizeof("REQUEST_URI"));
suhosin_server_encode(svars, "QUERY_STRING", sizeof("QUERY_STRING"));
}
if (SUHOSIN_G(server_strip)) {
suhosin_server_strip(svars, "PHP_SELF", sizeof("PHP_SELF"));
suhosin_server_strip(svars, "PATH_INFO", sizeof("PATH_INFO"));
suhosin_server_strip(svars, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"));
suhosin_server_strip(svars, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"));
}
}
/* }}} */
/* Old Input filter */
unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) = NULL;
/* {{{ suhosin_input_filter_wrapper
*/
unsigned int suhosin_input_filter_wrapper(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)
{
zend_bool already_scanned = SUHOSIN_G(already_scanned);
SUHOSIN_G(already_scanned) = 0;
if (SUHOSIN_G(do_not_scan)) {
if (new_val_len) {
*new_val_len = val_len;
}
return 1;
}
if (!already_scanned) {
if (suhosin_input_filter(arg, var, val, val_len, new_val_len TSRMLS_CC)==0) {
SUHOSIN_G(abort_request)=1;
return 0;
}
if (new_val_len) {
val_len = *new_val_len;
}
}
if (old_input_filter) {
return old_input_filter(arg, var, val, val_len, new_val_len TSRMLS_CC);
} else {
return 1;
}
}
/* {{{ suhosin_input_filter
*/
unsigned int suhosin_input_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)
{
char *index, *prev_index = NULL;
unsigned int var_len, total_len, depth = 0;
/* Mark that we were called */
SUHOSIN_G(already_scanned) = 1;
if (new_val_len) {
*new_val_len = 0;
}
/* Drop this variable if the limit was reached */
switch (arg) {
case PARSE_GET:
SUHOSIN_G(att_get_vars)++;
SUHOSIN_G(att_request_variables)++;
if (SUHOSIN_G(no_more_get_variables)) {
return 0;
}
break;
case PARSE_POST:
SUHOSIN_G(att_post_vars)++;
SUHOSIN_G(att_request_variables)++;
if (SUHOSIN_G(no_more_post_variables)) {
return 0;
}
break;
case PARSE_COOKIE:
SUHOSIN_G(att_cookie_vars)++;
SUHOSIN_G(att_request_variables)++;
if (SUHOSIN_G(no_more_cookie_variables)) {
return 0;
}
break;
default: /* we do not want to protect parse_str() and friends */
if (new_val_len) {
*new_val_len = val_len;
}
return 1;
}
/* Drop this variable if the limit is now reached */
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(max_get_vars) && SUHOSIN_G(max_get_vars) <= SUHOSIN_G(cur_get_vars)) {
suhosin_log(S_VARS, "configured GET variable limit exceeded - dropped variable '%s' - all further GET variables are dropped", var);
if (!SUHOSIN_G(simulation)) {
SUHOSIN_G(no_more_get_variables) = 1;
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(max_cookie_vars) && SUHOSIN_G(max_cookie_vars) <= SUHOSIN_G(cur_cookie_vars)) {
suhosin_log(S_VARS, "configured COOKIE variable limit exceeded - dropped variable '%s' - all further COOKIE variables are dropped", var);
if (!SUHOSIN_G(simulation)) {
SUHOSIN_G(no_more_cookie_variables) = 1;
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(max_post_vars) && SUHOSIN_G(max_post_vars) <= SUHOSIN_G(cur_post_vars)) {
suhosin_log(S_VARS, "configured POST variable limit exceeded - dropped variable '%s' - all further POST variables are dropped", var);
if (!SUHOSIN_G(simulation)) {
SUHOSIN_G(no_more_post_variables) = 1;
return 0;
}
}
break;
}
/* Drop this variable if it begins with whitespace which is disallowed */
if (isspace(*var)) {
if (SUHOSIN_G(disallow_ws)) {
suhosin_log(S_VARS, "request variable name begins with disallowed whitespace - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(disallow_get_ws)) {
suhosin_log(S_VARS, "GET variable name begins with disallowed whitespace - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(disallow_post_ws)) {
suhosin_log(S_VARS, "POST variable name begins with disallowed whitespace - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(disallow_cookie_ws)) {
suhosin_log(S_VARS, "COOKIE variable name begins with disallowed whitespace - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
}
}
/* Drop this variable if it exceeds the value length limit */
if (SUHOSIN_G(max_value_length) && SUHOSIN_G(max_value_length) < val_len) {
suhosin_log(S_VARS, "configured request variable value length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(max_get_value_length) && SUHOSIN_G(max_get_value_length) < val_len) {
suhosin_log(S_VARS, "configured GET variable value length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(max_cookie_value_length) && SUHOSIN_G(max_cookie_value_length) < val_len) {
suhosin_log(S_VARS, "configured COOKIE variable value length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(max_post_value_length) && SUHOSIN_G(max_post_value_length) < val_len) {
suhosin_log(S_VARS, "configured POST variable value length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
}
/* 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_VARS, "configured request variable name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
if (SUHOSIN_G(max_totalname_length) && SUHOSIN_G(max_totalname_length) < total_len) {
suhosin_log(S_VARS, "configured request variable total name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(max_get_name_length) && SUHOSIN_G(max_get_name_length) < var_len) {
suhosin_log(S_VARS, "configured GET variable name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
if (SUHOSIN_G(max_get_totalname_length) && SUHOSIN_G(max_get_totalname_length) < total_len) {
suhosin_log(S_VARS, "configured GET variable total name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(max_cookie_name_length) && SUHOSIN_G(max_cookie_name_length) < var_len) {
suhosin_log(S_VARS, "configured COOKIE variable name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
if (SUHOSIN_G(max_cookie_totalname_length) && SUHOSIN_G(max_cookie_totalname_length) < total_len) {
suhosin_log(S_VARS, "configured COOKIE variable total name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(max_post_name_length) && SUHOSIN_G(max_post_name_length) < var_len) {
suhosin_log(S_VARS, "configured POST variable name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
if (SUHOSIN_G(max_post_totalname_length) && SUHOSIN_G(max_post_totalname_length) < total_len) {
suhosin_log(S_VARS, "configured POST variable total name length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
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 (SUHOSIN_G(max_array_index_length) && SUHOSIN_G(max_array_index_length) < index_length) {
suhosin_log(S_VARS, "configured request variable array index length limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(max_get_array_index_length) && SUHOSIN_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 (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(max_cookie_array_index_length) && SUHOSIN_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 (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(max_post_array_index_length) && SUHOSIN_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 (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
}
/* 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) {
suhosin_log(S_VARS, "array index contains not whitelisted characters - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
} else if (SUHOSIN_G(array_index_blacklist) && *(SUHOSIN_G(array_index_blacklist))) {
if (suhosin_strncspn(index, index_length, SUHOSIN_G(array_index_blacklist)) != index_length) {
suhosin_log(S_VARS, "array index contains blacklisted characters - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
}
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_VARS, "configured request variable array depth limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(max_get_array_depth) && SUHOSIN_G(max_get_array_depth) < depth) {
suhosin_log(S_VARS, "configured GET variable array depth limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(max_cookie_array_depth) && SUHOSIN_G(max_cookie_array_depth) < depth) {
suhosin_log(S_VARS, "configured COOKIE variable array depth limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(max_post_array_depth) && SUHOSIN_G(max_post_array_depth) < depth) {
suhosin_log(S_VARS, "configured POST variable array depth limit exceeded - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
}
/* Check if variable value is truncated by a \0 */
if (val && *val && val_len != strnlen(*val, val_len)) {
if (SUHOSIN_G(disallow_nul)) {
suhosin_log(S_VARS, "ASCII-NUL chars not allowed within request variables - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
switch (arg) {
case PARSE_GET:
if (SUHOSIN_G(disallow_get_nul)) {
suhosin_log(S_VARS, "ASCII-NUL chars not allowed within GET variables - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_COOKIE:
if (SUHOSIN_G(disallow_cookie_nul)) {
suhosin_log(S_VARS, "ASCII-NUL chars not allowed within COOKIE variables - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
break;
case PARSE_POST:
if (SUHOSIN_G(disallow_post_nul)) {
suhosin_log(S_VARS, "ASCII-NUL chars not allowed within POST variables - dropped variable '%s'", var);
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
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)) {
suhosin_log(S_VARS, "tried to register forbidden variable '%s' through %s variables", var, arg == PARSE_GET ? "GET" : arg == PARSE_POST ? "POST" : "COOKIE");
if (!SUHOSIN_G(simulation)) {
return 0;
}
}
/* Okay let PHP register this variable */
SUHOSIN_G(cur_request_variables)++;
switch (arg) {
case PARSE_GET:
SUHOSIN_G(cur_get_vars)++;
break;
case PARSE_COOKIE:
SUHOSIN_G(cur_cookie_vars)++;
break;
case PARSE_POST:
SUHOSIN_G(cur_post_vars)++;
break;
}
if (new_val_len) {
*new_val_len = val_len;
}
return 1;
}
/* }}} */
/* {{{ suhosin_hook_register_server_variables
*/
void suhosin_hook_register_server_variables()
{
if (sapi_module.register_server_variables) {
orig_register_server_variables = sapi_module.register_server_variables;
sapi_module.register_server_variables = suhosin_register_server_variables;
}
}
/* }}} */
/*
* 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
*/
================================================
FILE: log.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/*
$Id: log.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_suhosin.h"
#include <fcntl.h>
#include "SAPI.h"
#include "ext/standard/datetime.h"
#include "ext/standard/flock_compat.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#elif defined(PHP_WIN32)
#include "win32/time.h"
#endif
#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
#undef AF_UNIX
#endif
#if defined(AF_UNIX)
#include <sys/un.h>
#endif
#define SYSLOG_PATH "/dev/log"
#include "snprintf.h"
#ifdef PHP_WIN32
static HANDLE log_source = 0;
#endif
#include <sys/file.h>
static char *loglevel2string(int loglevel)
{
switch (loglevel) {
case S_FILES:
return "FILES";
case S_INCLUDE:
return "INCLUDE";
case S_MEMORY:
return "MEMORY";
case S_MISC:
return "MISC";
case S_MAIL:
return "MAIL";
case S_SESSION:
return "SESSION";
case S_SQL:
return "SQL";
case S_EXECUTOR:
return "EXECUTOR";
case S_VARS:
return "VARS";
default:
return "UNKNOWN";
}
}
static char *month_names[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
PHP_SUHOSIN_API void suhosin_log(int loglevel, char *fmt, ...)
{
int s, r, i=0, fd;
long written, towrite;
int getcaller=0;
char *wbuf;
struct timeval tv;
time_t now;
struct tm tm;
#if defined(AF_UNIX)
struct sockaddr_un saun;
#endif
#ifdef PHP_WIN32
LPTSTR strs[2];
unsigned short etype;
DWORD evid;
#endif
char buf[5000] = {0};
char error[5000] = {0};
char *ip_address;
char *fname;
char *alertstring;
int lineno = 0;
va_list ap;
TSRMLS_FETCH();
#if PHP_VERSION_ID >= 50500
getcaller = (loglevel & S_GETCALLER) == S_GETCALLER;
#endif
/* remove the S_GETCALLER flag */
loglevel = loglevel & ~S_GETCALLER;
SDEBUG("(suhosin_log) loglevel: %d log_syslog: %ld - log_sapi: %ld - log_script: %ld", loglevel, SUHOSIN_G(log_syslog), SUHOSIN_G(log_sapi), SUHOSIN_G(log_script));
/* dump core if wanted */
if (SUHOSIN_G(coredump) && loglevel == S_MEMORY) {
volatile unsigned int *x = 0;
volatile int y = *x;
}
if (SUHOSIN_G(log_use_x_forwarded_for)) {
ip_address = suhosin_getenv("HTTP_X_FORWARDED_FOR", 20 TSRMLS_CC);
if (ip_address == NULL) {
ip_address = "X-FORWARDED-FOR not set";
}
} else {
ip_address = suhosin_getenv("REMOTE_ADDR", 11 TSRMLS_CC);
if (ip_address == NULL) {
ip_address = "REMOTE_ADDR not set";
}
}
va_start(ap, fmt);
ap_php_vsnprintf(error, sizeof(error), fmt, ap);
va_end(ap);
if (SUHOSIN_G(log_max_error_length) > 0 && SUHOSIN_G(log_max_error_length) < (sizeof(error) - 4)) {
memcpy(error + SUHOSIN_G(log_max_error_length), "...", 4);
}
while (error[i]) {
if (error[i] < 32) error[i] = '.';
i++;
}
if (SUHOSIN_G(simulation)) {
alertstring = "ALERT-SIMULATION";
} else {
alertstring = "ALERT";
}
if (zend_is_executing(TSRMLS_C)) {
zend_execute_data *exdata = EG(current_execute_data);
if (exdata) {
if (getcaller && exdata->prev_execute_data && exdata->prev_execute_data->opline && exdata->prev_execute_data->op_array) {
lineno = exdata->prev_execute_data->opline->lineno;
fname = (char *)exdata->prev_execute_data->op_array->filename;
} else if (exdata->opline && exdata->op_array) {
lineno = exdata->opline->lineno;
fname = (char *)exdata->op_array->filename;
} else {
lineno = 0;
fname = "[unknown filename]";
}
} else {
lineno = zend_get_executed_lineno(TSRMLS_C);
fname = (char *)zend_get_executed_filename(TSRMLS_C);
}
ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s', line %u)", alertstring, error, ip_address, fname, lineno);
} else {
fname = suhosin_getenv("SCRIPT_FILENAME", 15 TSRMLS_CC);
if (fname==NULL) {
fname = "unknown";
}
ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname);
}
/* Syslog-Logging disabled? */
if (((SUHOSIN_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)(SUHOSIN_G(log_syslog_facility)|SUHOSIN_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);
s = socket(AF_UNIX, SOCK_STREAM, 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);
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 (SUHOSIN_G(log_syslog_priority)) { /* translate UNIX type into NT type */
case 1: /*LOG_ALERT:*/
etype = EVENTLOG_ERROR_TYPE;
break;
case 6: /*LOG_INFO:*/
etype = EVENTLOG_INFORMATION_TYPE;
break;
default:
etype = EVENTLOG_WARNING_TYPE;
}
evid = loglevel;
strs[0] = error;
/* report the event */
if (log_source == NULL) {
log_source = RegisterEventSource(NULL, "Suhosin-" SUHOSIN_EXT_VERSION);
}
ReportEvent(log_source, etype, (unsigned short) SUHOSIN_G(log_syslog_priority), evid, NULL, 1, 0, strs, NULL);
#endif
log_file:
/* File-Logging disabled? */
if ((SUHOSIN_G(log_file) & loglevel)==0) {
goto log_sapi;
}
if (!SUHOSIN_G(log_filename) || !SUHOSIN_G(log_filename)[0]) {
goto log_sapi;
}
fd = open(SUHOSIN_G(log_filename), O_CREAT|O_APPEND|O_WRONLY, 0640);
if (fd == -1) {
suhosin_log(S_INTERNAL, "Unable to open logfile: %s", SUHOSIN_G(log_filename));
return;
}
if (SUHOSIN_G(log_file_time)) {
gettimeofday(&tv, NULL);
now = tv.tv_sec;
php_localtime_r(&now, &tm);
ap_php_snprintf(error, sizeof(error), "%s %2d %02d:%02d:%02d [%u] %s\n", month_names[tm.tm_mon], tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, getpid(),buf);
} else {
ap_php_snprintf(error, sizeof(error), "%s\n", buf);
}
towrite = strlen(error);
wbuf = error;
php_flock(fd, LOCK_EX);
while (towrite > 0) {
written = write(fd, wbuf, towrite);
if (written < 0) {
break;
}
towrite -= written;
wbuf += written;
}
php_flock(fd, LOCK_UN);
close(fd);
log_sapi:
/* SAPI Logging activated? */
SDEBUG("(suhosin_log) log_syslog: %ld - log_sapi: %ld - log_script: %ld - log_phpscript: %ld", SUHOSIN_G(log_syslog), SUHOSIN_G(log_sapi), SUHOSIN_G(log_script), SUHOSIN_G(log_phpscript));
if (((SUHOSIN_G(log_sapi)|S_INTERNAL) & loglevel)!=0) {
sapi_module.log_message(buf TSRMLS_CC);
}
if ((SUHOSIN_G(log_stdout) & loglevel)!=0) {
fprintf(stdout, "%s\n", buf);
}
/*log_script:*/
/* script logging activaed? */
if (((SUHOSIN_G(log_script) & loglevel)!=0) && SUHOSIN_G(log_scriptname)!=NULL) {
char cmd[8192], *cmdpos, *bufpos;
FILE *in;
int space;
struct stat st;
char *sname = SUHOSIN_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;
}
/* 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;
cmdpos = cmd + strlen(cmd);
bufpos = buf;
if (space <= 1) return;
while (space > 2 && *bufpos) {
if (*bufpos == '\'') {
if (space<=5) break;
*cmdpos++ = '\'';
*cmdpos++ = '\\';
*cmdpos++ = '\'';
*cmdpos++ = '\'';
bufpos++;
space-=4;
} else {
*cmdpos++ = *bufpos++;
space--;
}
}
*cmdpos++ = '\'';
*cmdpos++ = ' ';
*cmdpos++ = '2';
*cmdpos++ = '>';
*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;
}
/* read and forget the result */
while (1) {
int readbytes = fread(cmd, 1, sizeof(cmd), in);
if (readbytes<=0) {
break;
}
if (strncmp(cmd, "sh: ", 4) == 0) {
/* assume this is an error */
suhosin_log(S_INTERNAL, "Error while executing logging shell script: %s", sname);
pclose(in);
goto log_phpscript;
}
}
pclose(in);
}
log_phpscript:
if ((SUHOSIN_G(log_phpscript) & loglevel)!=0 && EG(in_execution) && SUHOSIN_G(log_phpscriptname) && SUHOSIN_G(log_phpscriptname)[0]) {
zend_file_handle file_handle;
zend_op_array *new_op_array;
zval *result = NULL;
long orig_execution_depth = SUHOSIN_G(execution_depth);
char *orig_basedir = PG(open_basedir);
char *phpscript = SUHOSIN_G(log_phpscriptname);
SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname));
if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) {
if (!file_handle.opened_path) {
file_handle.opened_path = estrndup(phpscript, strlen(phpscript));
}
new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
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);
SUHOSIN_G(execution_depth) = 0;
if (SUHOSIN_G(log_phpscript_is_safe)) {
PG(open_basedir) = NULL;
}
zend_execute(new_op_array TSRMLS_CC);
SUHOSIN_G(execution_depth) = orig_execution_depth;
PG(open_basedir) = orig_basedir;
destroy_op_array(new_op_array TSRMLS_CC);
efree(new_op_array);
if (!EG(exception))
{
if (EG(return_value_ptr_ptr)) {
zval_ptr_dtor(EG(return_value_ptr_ptr));
EG(return_value_ptr_ptr) = NULL;
}
}
} else {
suhosin_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SUHOSIN_G(log_phpscriptname));
return;
}
} else {
suhosin_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SUHOSIN_G(log_phpscriptname));
return;
}
}
}
/*
* 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
*/
================================================
FILE: mbregex/COPYING.LIB
================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
^L
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
^L
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
^L
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
^L
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
^L
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
^L
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
^L
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
^L
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).
To apply these terms, attach the following notices to the library.
It is safest to attach them to the start of each source file to most
effectively convey the exclusion of warranty; and each file should
have at least the "copyright" line and a pointer to where the full
notice is found.
<one line to give the library's name and a brief idea of what it
does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper
mail.
You should also get your employer (if you work as a programmer) or
your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James
Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
================================================
FILE: mbregex/mbregex.h
================================================
/* Definitions for data structures and routines for the regular
expression library, version 0.12.
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
Last change: May 21, 1993 by t^2 */
/* modified for Ruby by matz@netlab.co.jp */
#ifndef __MB_REGEXP_LIBRARY
#define __MB_REGEXP_LIBRARY
#include <stddef.h>
/* Define number of parens for which we record the beginnings and ends.
This affects how much space the `struct re_registers' type takes up. */
#ifndef MBRE_NREGS
#define MBRE_NREGS 10
#endif
#define MBRE_BYTEWIDTH 8
#define MBRE_REG_MAX ((1<<MBRE_BYTEWIDTH)-1)
/* Maximum number of duplicates an interval can allow. */
#ifndef MBRE_DUP_MAX
#define MBRE_DUP_MAX ((1 << 15) - 1)
#endif
/* If this bit is set, then character classes are supported; they are:
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
If not set, then character classes are not supported. */
#define MBRE_CHAR_CLASSES (1L << 9)
/* match will be done case insensetively */
#define MBRE_OPTION_IGNORECASE (1L)
/* perl-style extended pattern available */
#define MBRE_OPTION_EXTENDED (MBRE_OPTION_IGNORECASE<<1)
/* newline will be included for . */
#define MBRE_OPTION_MULTILINE (MBRE_OPTION_EXTENDED<<1)
/* ^ and $ ignore newline */
#define MBRE_OPTION_SINGLELINE (MBRE_OPTION_MULTILINE<<1)
/* works line Perl's /s; it's called POSIX for wrong reason */
#define MBRE_OPTION_POSIXLINE (MBRE_OPTION_MULTILINE|MBRE_OPTION_SINGLELINE)
/* search for longest match, in accord with POSIX regexp */
#define MBRE_OPTION_LONGEST (MBRE_OPTION_SINGLELINE<<1)
#define MBRE_MAY_IGNORECASE (MBRE_OPTION_LONGEST<<1)
#define MBRE_OPTIMIZE_ANCHOR (MBRE_MAY_IGNORECASE<<1)
#define MBRE_OPTIMIZE_EXACTN (MBRE_OPTIMIZE_ANCHOR<<1)
#define MBRE_OPTIMIZE_NO_BM (MBRE_OPTIMIZE_EXACTN<<1)
#define MBRE_OPTIMIZE_BMATCH (MBRE_OPTIMIZE_NO_BM<<1)
/* For multi-byte char support */
#define MBCTYPE_ASCII 0
#define MBCTYPE_EUC 1
#define MBCTYPE_SJIS 2
#define MBCTYPE_UTF8 3
#if 0
#if defined IMPORT || defined USEIMPORTLIB
extern __declspec(dllimport)
#elif defined EXPORT
extern __declspec(dllexport)
#else
extern
#endif
const unsigned char *re_mbctab;
#if defined(__STDC__)
void re_mbcinit (int);
#else
void re_mbcinit ();
#endif
#endif
#undef ismbchar
#define ismbchar(c) re_mbctab[(unsigned char)(c)]
#define mbclen(c) (re_mbctab[(unsigned char)(c)]+1)
/* Structure used in re_match() */
typedef union
{
unsigned char *word;
struct {
unsigned is_active : 1;
unsigned matched_something : 1;
} bits;
} mbre_register_info_type;
/* This data structure is used to represent a compiled pattern. */
struct mbre_pattern_buffer
{
char *buffer; /* Space holding the compiled pattern commands. */
int allocated; /* Size of space that `buffer' points to. */
int used; /* Length of portion of buffer actually occupied */
char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
/* re_search uses the fastmap, if there is one,
to skip over totally implausible characters. */
char *must; /* Pointer to exact pattern which strings should have
to be matched. */
int *must_skip; /* Pointer to exact pattern skip table for bm_search */
char *stclass; /* Pointer to character class list at top */
long options; /* Flags for options such as extended_pattern. */
long re_nsub; /* Number of subexpressions found by the compiler. */
char fastmap_accurate;
/* Set to zero when a new pattern is stored,
set to one when the fastmap is updated from it. */
char can_be_null; /* Set to one by compiling fastmap
if this pattern might match the null string.
It does not necessarily match the null string
in that case, but if this is zero, it cannot.
2 as value means can match null string
but at end of range or before a character
listed in the fastmap. */
/* stack & working area for re_match() */
unsigned char **regstart;
unsigned char **regend;
unsigned char **old_regstart;
unsigned char **old_regend;
mbre_register_info_type *reg_info;
unsigned char **best_regstart;
unsigned char **best_regend;
int mbctype;
};
typedef struct mbre_pattern_buffer mb_regex_t;
/* Structure to store register contents data in.
Pass the address of such a structure as an argument to re_match, etc.,
if you want this information back.
For i from 1 to MBRE_NREGS - 1, start[i] records the starting index in
the string of where the ith subexpression matched, and end[i] records
one after the ending index. start[0] and end[0] are analogous, for
the entire pattern. */
struct mbre_registers
{
int allocated;
int num_regs;
int *beg;
int *end;
};
#if 0
/* Type for byte offsets within the string. POSIX mandates this. */
typedef size_t regoff_t;
/* POSIX specification for registers. Aside from the different names than
`mbre_registers', POSIX uses an array of structures, instead of a
structure of arrays. */
typedef struct
{
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
} regmatch_t;
#endif
#ifdef __STDC__
extern char *mbre_compile_pattern (const char *, int, struct mbre_pattern_buffer *);
void mbre_free_pattern (struct mbre_pattern_buffer *);
/* Is this really advertised? */
extern int mbre_adjust_startpos (struct mbre_pattern_buffer *, const char*, int, int, int);
extern void mbre_compile_fastmap (struct mbre_pattern_buffer *);
extern int mbre_search (struct mbre_pattern_buffer *, const char*, int, int, int,
struct mbre_registers *);
extern int mbre_match (struct mbre_pattern_buffer *, const char *, int, int,
struct mbre_registers *);
extern void mbre_set_casetable (const char *table);
extern void mbre_copy_registers (struct mbre_registers*, struct mbre_registers*);
extern void mbre_free_registers (struct mbre_registers*);
#else /* !__STDC__ */
extern char *mbre_compile_pattern ();
void mbre_free_pattern ();
/* Is this really advertised? */
extern int mbre_adjust_startpos ();
extern void mbre_compile_fastmap ();
extern int mbre_search ();
extern int mbre_match ();
extern void mbre_set_casetable ();
extern void mbre_copy_registers ();
extern void mbre_free_registers ();
#endif /* __STDC__ */
#endif /* !__MB_REGEXP_LIBRARY */
================================================
FILE: mbregex.h
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/* $Id: mbregex.h,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ */
#if HAVE_MBREGEX
#include "mbregex/mbregex.h"
#endif
================================================
FILE: memory_limit.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/*
$Id: memory_limit.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_suhosin.h"
/* {{{ PHP_INI_MH
*/
static PHP_INI_MH(suhosin_OnChangeMemoryLimit)
{
#if SIZEOF_LONG==8
long hard_memory_limit = 0x7fffffffffffffff;
#elif SIZEOF_LONG==4
long hard_memory_limit = 0x7fffffff;
#endif /* will produce a compile error or SIZEOF_LONG is not 4 or 8 */
if (stage == ZEND_INI_STAGE_RUNTIME) {
if (SUHOSIN_G(memory_limit) > 0) {
SUHOSIN_G(hard_memory_limit) = SUHOSIN_G(memory_limit);
} else if (SUHOSIN_G(hard_memory_limit) == 0) {
SUHOSIN_G(hard_memory_limit) = PG(memory_limit);
}
hard_memory_limit = SUHOSIN_G(hard_memory_limit);
} else {
SUHOSIN_G(hard_memory_limit) = 0;
}
if (new_value) {
PG(memory_limit) = zend_atol(new_value, new_value_length);
if (hard_memory_limit > 0) {
if (PG(memory_limit) > hard_memory_limit) {
suhosin_log(S_MISC, "script tried to increase memory_limit to %lu bytes which is above the allowed value", PG(memory_limit));
if (!SUHOSIN_G(simulation)) {
PG(memory_limit) = hard_memory_limit;
return FAILURE;
}
} else if (PG(memory_limit) < 0) {
suhosin_log(S_MISC, "script tried to disable memory_limit by setting it to a negative value %ld bytes which is not allowed", PG(memory_limit));
if (!SUHOSIN_G(simulation)) {
PG(memory_limit) = hard_memory_limit;
return FAILURE;
}
}
}
} else {
PG(memory_limit) = hard_memory_limit;
}
return zend_set_memory_limit(PG(memory_limit));
}
/* }}} */
void suhosin_hook_memory_limit(TSRMLS_D)
{
zend_ini_entry *ini_entry;
/* check if we are compiled against memory_limit */
if (zend_hash_find(EG(ini_directives), "memory_limit", sizeof("memory_limit"), (void **) &ini_entry)==FAILURE) {
return;
}
/* replace OnUpdateMemoryLimit handler */
ini_entry->on_modify = suhosin_OnChangeMemoryLimit;
}
/*
* 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
*/
================================================
FILE: php_suhosin.h
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Stefan Esser <sesser@sektioneins.de> |
+----------------------------------------------------------------------+
*/
/* $Id: php_suhosin.h,v 1.4 2008-01-13 22:50:37 sesser Exp $ */
#ifndef PHP_SUHOSIN_H
#define PHP_SUHOSIN_H
#define SUHOSIN_EXT_VERSION "0.9.39dev2"
/*#define SUHOSIN_DEBUG*/
#define SUHOSIN_LOG "/tmp/suhosin_log.txt"
#ifdef PHP_WIN32
#define SDEBUG
#else
#ifdef SUHOSIN_DEBUG
#define SDEBUG(msg...) \
{FILE *f;f=fopen(SUHOSIN_LOG, "a+");if(f){fprintf(f,"[%u] ",getpid());fprintf(f, msg);fprintf(f,"\n");fclose(f);}}
#else
#define SDEBUG(msg...)
#endif
#endif
#ifndef PHP_VERSION_ID
#define PHP_VERSION_ID (PHP_MAJOR_VERSION * 10000 + PHP_MINOR_VERSION * 100 + PHP_RELEASE_VERSION)
#endif
extern zend_module_entry suhosin_module_entry;
#define phpext_suhosin_ptr &suhosin_module_entry
#ifdef PHP_WIN32
#define PHP_SUHOSIN_API __declspec(dllexport)
#else
#define PHP_SUHOSIN_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
/*#define STATIC static*/
#define STATIC
#define BYTE unsigned char /* 8 bits */
#define WORD unsigned int /* 32 bits */
PHP_MINIT_FUNCTION(suhosin);
PHP_MSHUTDOWN_FUNCTION(suhosin);
PHP_RINIT_FUNCTION(suhosin);
PHP_RSHUTDOWN_FUNCTION(suhosin);
PHP_MINFO_FUNCTION(suhosin);
#include "ext/standard/basic_functions.h"
static inline int suhosin_is_protected_varname(char *var, int var_len)
{
switch (var_len) {
case 18:
if (memcmp(var, "HTTP_RAW_POST_DATA", 18)==0) goto protected_varname;
break;
case 17:
if (memcmp(var, "HTTP_SESSION_VARS", 17)==0) goto protected_varname;
break;
case 16:
if (memcmp(var, "HTTP_SERVER_VARS", 16)==0) goto protected_varname;
if (memcmp(var, "HTTP_COOKIE_VARS", 16)==0) goto protected_varname;
break;
case 15:
if (memcmp(var, "HTTP_POST_FILES", 15)==0) goto protected_varname;
break;
case 14:
if (memcmp(var, "HTTP_POST_VARS", 14)==0) goto protected_varname;
break;
case 13:
if (memcmp(var, "HTTP_GET_VARS", 13)==0) goto protected_varname;
if (memcmp(var, "HTTP_ENV_VARS", 13)==0) goto protected_varname;
break;
case 8:
if (memcmp(var, "_SESSION", 8)==0) goto protected_varname;
if (memcmp(var, "_REQUEST", 8)==0) goto protected_varname;
break;
case 7:
if (memcmp(var, "GLOBALS", 7)==0) goto protected_varname;
if (memcmp(var, "_COOKIE", 7)==0) goto protected_varname;
if (memcmp(var, "_SERVER", 7)==0) goto protected_varname;
break;
case 6:
if (memcmp(var, "_FILES", 6)==0) goto protected_varname;
break;
case 5:
if (memcmp(var, "_POST", 5)==0) goto protected_varname;
break;
case 4:
if (memcmp(var, "_ENV", 4)==0) goto protected_varname;
if (memcmp(var, "_GET", 4)==0) goto protected_varname;
break;
}
return 0;
protected_varname:
return 1;
}
ZEND_BEGIN_MODULE_GLOBALS(suhosin)
zend_uint in_code_type;
long execution_depth;
zend_bool simulation;
zend_bool stealth;
zend_bool protectkey;
zend_bool executor_allow_symlink;
char *filter_action;
char *sql_user_prefix;
char *sql_user_postfix;
char *sql_user_match;
long sql_comment;
long sql_opencomment;
long sql_union;
long sql_mselect;
long max_execution_depth;
zend_bool abort_request;
long executor_include_max_traversal;
zend_bool executor_include_allow_writable_files;
HashTable *include_whitelist;
HashTable *include_blacklist;
HashTable *func_whitelist;
HashTable *func_blacklist;
HashTable *eval_whitelist;
HashTable *eval_blacklist;
zend_bool executor_disable_eval;
zend_bool executor_disable_emod;
/* request variables */
long max_request_variables;
long cur_request_variables;
long att_request_variables;
long max_varname_length;
long max_totalname_length;
long max_value_length;
long max_array_depth;
long max_array_index_length;
char* array_index_whitelist;
char* array_index_blacklist;
zend_bool disallow_nul;
zend_bool disallow_ws;
/* cookie variables */
long max_cookie_vars;
long cur_cookie_vars;
long att_cookie_vars;
long max_cookie_name_length;
long max_cookie_totalname_length;
long max_cookie_value_length;
long max_cookie_array_depth;
long max_cookie_array_index_length;
zend_bool disallow_cookie_nul;
zend_bool disallow_cookie_ws;
/* get variables */
long max_get_vars;
long cur_get_vars;
long att_get_vars;
long max_get_name_length;
long max_get_totalname_length;
long max_get_value_length;
long max_get_array_depth;
long max_get_array_index_length;
zend_bool disallow_get_nul;
zend_bool disallow_get_ws;
/* post variables */
long max_post_vars;
long cur_post_vars;
long att_post_vars;
long max_post_name_length;
long max_post_totalname_length;
long max_post_value_length;
long max_post_array_depth;
long max_post_array_index_length;
zend_bool disallow_post_nul;
zend_bool disallow_post_ws;
/* fileupload */
long upload_limit;
long upload_max_newlines;
long num_uploads;
zend_bool upload_disallow_elf;
zend_bool upload_disallow_binary;
zend_bool upload_remove_binary;
#ifdef SUHOSIN_EXPERIMENTAL
zend_bool upload_allow_utf8;
#endif
char *upload_verification_script;
zend_bool no_more_variables;
zend_bool no_more_get_variables;
zend_bool no_more_post_variables;
zend_bool no_more_cookie_variables;
zend_bool no_more_uploads;
/* log */
zend_bool log_use_x_forwarded_for;
long log_syslog;
long log_syslog_facility;
long log_syslog_priority;
long log_script;
long log_sapi;
long log_stdout;
char *log_scriptname;
long log_phpscript;
char *log_phpscriptname;
zend_bool log_phpscript_is_safe;
long log_file;
char *log_filename;
zend_bool log_file_time;
long log_max_error_length;
/* header handler */
zend_bool allow_multiheader;
/* mailprotect */
long mailprotect;
/* memory_limit */
long memory_limit;
long hard_memory_limit;
/* sqlprotect */
zend_bool sql_bailout_on_error;
int (*old_php_body_write)(const char *str, unsigned int str_length TSRMLS_DC);
/* session */
void *s_module;
void *s_original_mod;
int (*old_s_read)(void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC);
int (*old_s_write)(void **mod_data, const char *key, const char *val, const int vallen TSRMLS_DC);
int (*old_s_destroy)(void **mod_data, const char *key TSRMLS_DC);
BYTE fi[24],ri[24];
WORD fkey[120];
WORD rkey[120];
zend_bool session_encrypt;
char* session_cryptkey;
zend_bool session_cryptua;
zend_bool session_cryptdocroot;
long session_cryptraddr;
long session_checkraddr;
long session_max_id_length;
char* decrypted_cookie;
char* raw_cookie;
zend_bool cookie_encrypt;
char* cookie_cryptkey;
zend_bool cookie_cryptua;
zend_bool cookie_cryptdocroot;
long cookie_cryptraddr;
long cookie_checkraddr;
HashTable *cookie_plainlist;
HashTable *cookie_cryptlist;
zend_bool coredump;
zend_bool apc_bug_workaround;
zend_bool already_scanned;
zend_bool do_not_scan;
zend_bool server_encode;
zend_bool server_strip;
zend_bool disable_display_errors;
php_uint32 r_state[625];
php_uint32 *r_next;
int r_left;
zend_bool srand_ignore;
zend_bool mt_srand_ignore;
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 mt_is_seeded;
/* PERDIR Handling */
char *perdir;
zend_bool log_perdir;
zend_bool exec_perdir;
zend_bool get_perdir;
zend_bool post_perdir;
zend_bool cookie_perdir;
zend_bool request_perdir;
zend_bool upload_perdir;
zend_bool sql_perdir;
zend_bool misc_perdir;
ZEND_END_MODULE_GLOBALS(suhosin)
#ifdef ZTS
#define SUHOSIN_G(v) TSRMG(suhosin_globals_id, zend_suhosin_globals *, v)
#else
#define SUHOSIN_G(v) (suhosin_globals.v)
#endif
#ifndef ZEND_INI_STAGE_HTACCESS
#define ZEND_INI_STAGE_HTACCESS (1<<5)
#endif
/* Error Constants */
#ifndef S_MEMORY
#define S_MEMORY (1<<0L)
#define S_MISC (1<<1L)
#define S_VARS (1<<2L)
#define S_FILES (1<<3L)
#define S_INCLUDE (1<<4L)
#define S_SQL (1<<5L)
#define S_EXECUTOR (1<<6L)
#define S_MAIL (1<<7L)
#define S_SESSION (1<<8L)
#define S_INTERNAL (1<<29L)
#define S_ALL (S_MEMORY | S_VARS | S_INCLUDE | S_FILES | S_MAIL | S_SESSION | S_MISC | S_SQL | S_EXECUTOR)
#endif
#ifndef S_GETCALLER
#define S_GETCALLER (1<<30L)
#endif
#define SUHOSIN_NORMAL 0
#define SUHOSIN_EVAL 1
#define SUHOSIN_FLAG_CREATED_BY_EVAL 1
#define SUHOSIN_FLAG_NOT_EVALED_CODE 2
ZEND_EXTERN_MODULE_GLOBALS(suhosin)
static inline char *
suhosin_str_tolower_dup(const char *source, unsigned int length)
{
register char *dup = estrndup(source, length);
zend_str_tolower(dup, length);
return dup;
}
/* functions */
PHP_SUHOSIN_API void suhosin_log(int loglevel, char *fmt, ...);
char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key TSRMLS_DC);
char *suhosin_decrypt_string(char *str, int padded_len, char *var, int vlen, char *key, int *orig_len, int check_ra TSRMLS_DC);
char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, char *cryptkey TSRMLS_DC);
char *suhosin_cookie_decryptor(TSRMLS_D);
char *suhosin_getenv(char *name, size_t name_len TSRMLS_DC);
void suhosin_hook_post_handlers(TSRMLS_D);
void suhosin_unhook_post_handlers(TSRMLS_D);
void suhosin_hook_register_server_variables();
void suhosin_hook_header_handler();
void suhosin_unhook_header_handler();
void suhosin_hook_session(TSRMLS_D);
void suhosin_unhook_session(TSRMLS_D);
void suhosin_hook_sha256(TSRMLS_D);
#if defined(__OpenBSD__) && defined(SUHOSIN_EXPERIMENTAL)
void suhosin_hook_pledge(TSRMLS_D);
#endif
void suhosin_hook_ex_imp(TSRMLS_D);
void suhosin_hook_treat_data();
void suhosin_hook_memory_limit(TSRMLS_D);
void suhosin_hook_execute(TSRMLS_D);
void suhosin_unhook_execute();
void suhosin_aes_gentables();
void suhosin_aes_gkey(int nb,int nk,char *key TSRMLS_DC);
void suhosin_aes_encrypt(char *buff TSRMLS_DC);
void suhosin_aes_decrypt(char *buff TSRMLS_DC);
unsigned int suhosin_input_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
unsigned int suhosin_input_filter_wrapper(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
extern unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
void normalize_varname(char *varname);
int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TSRMLS_DC);
void suhosin_bailout(TSRMLS_D);
size_t suhosin_strnspn(const char *input, size_t n, const char *accept);
size_t suhosin_strncspn(const char *input, size_t n, const char *reject);
#endif /* PHP_SUHOSIN_H */
/*
* 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
*/
================================================
FILE: pkg/build_deb.sh
================================================
#!/bin/bash
_exit() {
echo "[E] bye."
exit 1
}
yn_or_exit() {
echo -n "[?] OK? [y] "
read yn
if [ "$yn" != "" -a "$yn" != "y" ]; then
_exit
fi
}
##
echo "[*] checking prerequisites..."
for i in phpize make install fakeroot php-config dpkg-deb dpkg-architecture; do
if [ "`which $i`" == "" ]; then
echo "[E] please install '$i' and try again."
_exit
fi
done
##
HERE=`(cd $(dirname $0); pwd)`
SUHOSIN=$HERE/..
ROOT=$HERE/tmp
PKGDIR=$HERE
PHP_EX=`php-config --extension-dir`
eval `dpkg-architecture -l`
VERSION=${SUHOSIN_VERSION:-$1}
if [ "$VERSION" == "" ]; then
echo "[E] please set SUHOSIN_VERSION, e.g. $0 0.9.36-1~dev1"
_exit
fi
echo "[*] -----------------------------------------------------------"
echo "[+] suhosin dir: $SUHOSIN"
echo "[+] tmp dir: $ROOT"
echo "[+] PHP extension dir: $PHP_EX"
echo "[+] architecture: $DEB_HOST_ARCH"
echo "[+] suhosin deb version: $VERSION"
echo "[+] pkg output dir: $PKGDIR"
yn_or_exit
if [ ! -f "$SUHOSIN/modules/suhosin.so" ]; then
echo "[+] Cannot find suhosin.so. I will try to build it."
yn_or_exit
eval `dpkg-buildflags --export=sh`
if [ ! -f "$SUHOSIN/configure" ]; then
echo "[*] phpize"
cd $SUHOSIN
phpize || _exit
fi
if [ ! -f "$SUHOSIN/Makefile" ]; then
echo "[*] configure"
cd $SUHOSIN
./configure --enable-suhosin-experimental
fi
echo "[*] make"
make clean
make -C $SUHOSIN || _exit
fi
##
echo "[*] deb"
if [ -d "$ROOT" ]; then
echo "[+] tmp dir $ROOT already exists. Delete?"
yn_or_exit
rm -rf $ROOT
fi
##
mkdir -p $ROOT/DEBIAN
#echo "9" >$ROOT/DEBIAN/compat
cat >$ROOT/DEBIAN/control <<EOF
Package: php5-suhosin-extension
Section: php
Priority: extra
Maintainer: Ben Fuhrmannek <ben@sektioneins.de>
Homepage: http://www.suhosin.org/
Conflicts: php5-suhosin
Depends: php5-common
Description: advanced protection system for PHP5
This package provides a PHP hardening module.
.
Suhosin is an advanced protection system for PHP installations. It was
designed to protect servers and users from known and unknown flaws in PHP
applications and the PHP core. Suhosin comes in two independent parts, that
can be used separately or in combination. The first part is a small patch
against the PHP core, that implements a few low-level protections against
bufferoverflows or format string vulnerabilities and the second part is a
powerful PHP extension that implements all the other protections.
.
This Package provides the suhosin extension only.
EOF
echo "Architecture: $DEB_HOST_ARCH" >>$ROOT/DEBIAN/control
echo "Version: $VERSION" >>$ROOT/DEBIAN/control
echo "/etc/php5/mods-available/suhosin.ini" >$ROOT/DEBIAN/conffiles
install -d -g 0 -o 0 $ROOT$PHP_EX
install -g 0 -o 0 -m 644 $SUHOSIN/modules/suhosin.so $ROOT$PHP_EX
install -d -g 0 -o 0 $ROOT/usr/share/doc/php5-suhosin-extension
install -g 0 -o 0 -m 644 $SUHOSIN/suhosin.ini $ROOT/usr/share/doc/php5-suhosin-extension/suhosin.ini.example
install -d -g 0 -o 0 $ROOT/etc/php5/mods-available
( echo '; priority=70' ; sed -e 's/^;extension=/extension=/' $SUHOSIN/suhosin.ini ) >$ROOT/etc/php5/mods-available/suhosin.ini
chown root:root $ROOT/etc/php5/mods-available/suhosin.ini
fakeroot dpkg-deb -b $ROOT $PKGDIR
echo "[*] done."
================================================
FILE: pledge.c
================================================
/*
+----------------------------------------------------------------------+
| Suhosin Version 1 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 The Hardened-PHP Project |
| Copyright (c) 2007-2015 SektionEins GmbH |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the fi
gitextract_i6z6y2bt/ ├── .gitignore ├── .travis.yml ├── CREDITS ├── Changelog ├── LICENSE ├── README.md ├── aes.c ├── config.m4 ├── config.w32 ├── crypt.c ├── ex_imp.c ├── execute.c ├── header.c ├── ifilter.c ├── log.c ├── mbregex/ │ ├── COPYING.LIB │ └── mbregex.h ├── mbregex.h ├── memory_limit.c ├── php_suhosin.h ├── pkg/ │ └── build_deb.sh ├── pledge.c ├── pledge.h ├── post_handler.c ├── rfc1867_new.c ├── session.c ├── sha256.c ├── sha256.h ├── suhosin.c ├── suhosin.ini ├── suhosin_logo.h ├── suhosin_rfc1867.h ├── tests/ │ ├── cookie/ │ │ ├── crypt.checkraddr_4.phpt │ │ ├── crypt.checkraddr_4_incorrect.phpt │ │ ├── crypt.cryptlist.phpt │ │ ├── crypt.docroot.phpt │ │ ├── crypt.invalid.phpt │ │ ├── crypt.key_default.phpt │ │ ├── crypt.key_empty.phpt │ │ ├── crypt.key_empty_remote_addr.phpt │ │ ├── crypt.no_encryption.phpt │ │ ├── crypt.plainlist.phpt │ │ ├── crypt.raddr_1.phpt │ │ ├── crypt.raddr_2.phpt │ │ ├── crypt.raddr_3.phpt │ │ ├── crypt.raddr_4.phpt │ │ └── crypt.ua.phpt │ ├── empty.inc │ ├── executor/ │ │ ├── allow_symlink_off.phpt │ │ ├── allow_symlink_on.phpt │ │ ├── disable_emod_off.phpt │ │ ├── disable_emod_on.phpt │ │ ├── disable_eval_off.phpt │ │ ├── disable_eval_on.phpt │ │ ├── eval_blacklist.phpt │ │ ├── eval_blacklist_printf.phpt │ │ ├── eval_blacklist_printf_function_exists.phpt │ │ ├── eval_whitelist_absmax.phpt │ │ ├── eval_whitelist_call_user_func.phpt │ │ ├── function_blacklist.phpt │ │ ├── function_blacklist_printf.phpt │ │ ├── function_blacklist_printf_function_exists.phpt │ │ ├── function_call_user_func.phpt │ │ ├── function_whitelist.phpt │ │ ├── function_whitelist_absmax.phpt │ │ ├── function_whitelist_call_user_func.phpt │ │ ├── function_whitelist_function_exists.phpt │ │ ├── function_whitelist_maxabs.phpt │ │ ├── function_whitelist_without_function_exists.phpt │ │ ├── memory_limit.phpt │ │ ├── memory_limit_64bit.phpt │ │ ├── memory_limit_64bit_10G.phpt │ │ ├── memory_limit_negative.phpt │ │ ├── memory_limit_other_hardlimit.phpt │ │ ├── preg_replace.phpt │ │ ├── preg_replace_error.phpt │ │ ├── recursion_maxdepth.phpt │ │ └── user_session_handler.phpt │ ├── filter/ │ │ ├── cookie_disallow_nul.phpt │ │ ├── cookie_disallow_ws.phpt │ │ ├── cookie_max_array_depth.phpt │ │ ├── cookie_max_array_index_length.phpt │ │ ├── cookie_max_name_length.phpt │ │ ├── cookie_max_totalname_length.phpt │ │ ├── cookie_max_value_length.phpt │ │ ├── cookie_max_vars.phpt │ │ ├── filter_action_302.phpt │ │ ├── filter_action_php.phpt │ │ ├── filter_logging_statistics.phpt │ │ ├── get_allow_ws.phpt │ │ ├── get_disallow_nul.phpt │ │ ├── get_disallow_ws.phpt │ │ ├── get_filter_1.phpt │ │ ├── get_filter_2.phpt │ │ ├── get_globals.phpt │ │ ├── get_max_array_depth.phpt │ │ ├── get_max_array_index_length.phpt │ │ ├── get_max_name_length.phpt │ │ ├── get_max_totalname_length.phpt │ │ ├── get_max_value_length.phpt │ │ ├── input_filter_allow_nul.phpt │ │ ├── input_filter_request_max_value_length.phpt │ │ ├── post_disallow_nul.phpt │ │ ├── post_disallow_nul_rfc1867.phpt │ │ ├── post_disallow_ws.phpt │ │ ├── post_fileupload_array_index_blacklist.phpt │ │ ├── post_fileupload_array_index_whitelist.phpt │ │ ├── post_fileupload_filter_1.phpt │ │ ├── post_fileupload_filter_2.phpt │ │ ├── post_filter_1.phpt │ │ ├── post_filter_2.phpt │ │ ├── post_filter_empty_avar.phpt │ │ ├── post_filter_empty_var.phpt │ │ ├── post_max_array_depth.phpt │ │ ├── post_max_array_depth_rfc1867.phpt │ │ ├── post_max_array_index_length.phpt │ │ ├── post_max_array_index_length_rfc1867.phpt │ │ ├── post_max_name_length.phpt │ │ ├── post_max_name_length_rfc1867.phpt │ │ ├── post_max_totalname_length.phpt │ │ ├── post_max_totalname_length_rfc1867.phpt │ │ ├── post_max_value_length.phpt │ │ ├── post_max_value_length_rfc1867.phpt │ │ ├── request_array_index_blacklist.phpt │ │ ├── request_array_index_whitelist.phpt │ │ ├── request_disallow_nul.phpt │ │ ├── request_disallow_ws.phpt │ │ ├── request_max_array_depth.phpt │ │ ├── request_max_array_index_length.phpt │ │ ├── request_max_name_length.phpt │ │ ├── request_max_totalname_length.phpt │ │ ├── server_encode_off.phpt │ │ ├── server_encode_on.phpt │ │ ├── server_filter.phpt │ │ ├── server_strip_off.phpt │ │ ├── server_strip_on.phpt │ │ ├── server_user_agent_strip_off.phpt │ │ ├── server_user_agent_strip_on.phpt │ │ ├── suhosin_upload_disallow_binary_off.phpt │ │ ├── suhosin_upload_disallow_binary_on.phpt │ │ ├── suhosin_upload_disallow_binary_utf8.phpt │ │ ├── suhosin_upload_disallow_binary_utf8fail.phpt │ │ ├── suhosin_upload_disallow_elf.phpt │ │ ├── suhosin_upload_disallow_elf_off.phpt │ │ ├── suhosin_upload_max_uploads.phpt │ │ ├── suhosin_upload_remove_binary.phpt │ │ ├── suhosin_upload_remove_binary_utf8.phpt │ │ └── suhosin_upload_remove_binary_utf8fail.phpt │ ├── funcs/ │ │ ├── crypt_blowfish.phpt │ │ ├── crypt_ext_des.phpt │ │ ├── crypt_md5.phpt │ │ ├── crypt_std_des.phpt │ │ └── sha256.phpt │ ├── include/ │ │ ├── include_allow_writable_files_off.phpt │ │ ├── include_allow_writable_files_on.phpt │ │ ├── include_blacklist.phpt │ │ ├── include_blackwhitelist_empty.phpt │ │ ├── include_constant.phpt │ │ ├── include_etc_passwd.phpt │ │ ├── include_max_traversal.phpt │ │ ├── include_nul_in_filename.phpt │ │ ├── include_once_constant.phpt │ │ ├── include_once_tmpvar.phpt │ │ ├── include_once_var.phpt │ │ ├── include_tmpvar.phpt │ │ ├── include_too_long.phpt │ │ ├── include_uploaded_file_diff_filename.phpt │ │ ├── include_uploaded_file_from_FILES.phpt │ │ ├── include_var.phpt │ │ ├── include_whitelist.phpt │ │ ├── require_constant.phpt │ │ ├── require_once_constant.phpt │ │ ├── require_once_tmpvar.phpt │ │ ├── require_once_var.phpt │ │ ├── require_tmpvar.phpt │ │ └── require_var.phpt │ ├── logging/ │ │ ├── log_max_error_length.phpt │ │ ├── logscript_executable.phpt │ │ ├── logscript_nonexecutable.phpt │ │ ├── logscript_nonexistant.phpt │ │ ├── use_x_forwarded_for_off.phpt │ │ ├── use_x_forwarded_for_off_no_remote_addr.phpt │ │ ├── use_x_forwarded_for_on.phpt │ │ └── use_x_forwarded_for_on_no_x_forwarded.phpt │ ├── misc/ │ │ ├── disable_display_errors_fail.phpt │ │ ├── disable_display_errors_off.phpt │ │ ├── disable_display_errors_on.phpt │ │ ├── mailprotect_1_header_nl.phpt │ │ ├── mailprotect_1_header_nlnl.phpt │ │ ├── mailprotect_1_subject.phpt │ │ ├── mailprotect_1_subject_long.phpt │ │ ├── mailprotect_1_to.phpt │ │ ├── mailprotect_1_to_long.phpt │ │ ├── mailprotect_2_bcc.phpt │ │ ├── mailprotect_2_cc.phpt │ │ ├── mailprotect_2_to.phpt │ │ ├── mt_srand_ignore_off.phpt │ │ ├── mt_srand_ignore_on.phpt │ │ ├── protectkey_off.phpt │ │ ├── protectkey_on.phpt │ │ ├── srand_ignore_off.phpt │ │ └── srand_ignore_on.phpt │ ├── session/ │ │ ├── PHPSESSID_max_id_length_ok.phpt │ │ ├── PHPSESSID_max_id_length_toolong.phpt │ │ ├── crypt.checkraddr_4.phpt │ │ ├── crypt.checkraddr_4_incorrect.phpt │ │ ├── crypt.docroot.phpt │ │ ├── crypt.key_default.phpt │ │ ├── crypt.key_empty.phpt │ │ ├── crypt.key_empty_remote_addr.phpt │ │ ├── crypt.no_encryption.phpt │ │ ├── crypt.raddr_1.phpt │ │ ├── crypt.raddr_2.phpt │ │ ├── crypt.raddr_3.phpt │ │ ├── crypt.raddr_4.phpt │ │ ├── crypt.ua.phpt │ │ ├── max_id_length_ok.phpt │ │ ├── max_id_length_toolong.phpt │ │ ├── session_recursive_crash.phpt │ │ ├── session_recursive_crash2.phpt │ │ └── sessionhandler.inc │ ├── skipif.inc │ ├── skipifcli.inc │ ├── skipifnotcli.inc │ └── sql/ │ ├── connect.inc │ ├── mysqli_comment_conditional.phpt │ ├── mysqli_comment_cstyle_fail.phpt │ ├── mysqli_comment_hashstyle_fail.phpt │ ├── mysqli_comment_sqlstyle.phpt │ ├── mysqli_comment_sqlstyle_fail.phpt │ ├── mysqli_connect_invalid_username.phpt │ ├── mysqli_multiselect.phpt │ ├── mysqli_multiselect_fail.phpt │ ├── mysqli_multiselect_subselect.phpt │ ├── mysqli_no_constraints.phpt │ ├── mysqli_open_comment.phpt │ ├── mysqli_open_comment_fail.phpt │ ├── mysqli_union.phpt │ ├── mysqli_union_fail.phpt │ ├── mysqli_user_match_error.phpt │ ├── mysqli_user_match_ok.phpt │ ├── mysqli_user_postfix.phpt │ ├── mysqli_user_prefix.phpt │ └── skipifmysqli.inc ├── treat_data.c └── ufilter.c
SYMBOL INDEX (186 symbols across 20 files)
FILE: aes.c
function WORD (line 61) | static WORD pack(BYTE *b)
function unpack (line 66) | static void unpack(WORD a,BYTE *b)
function BYTE (line 74) | static BYTE xtime(BYTE a)
function BYTE (line 84) | static BYTE bmul(BYTE x,BYTE y)
function WORD (line 90) | static WORD SubByte(WORD a)
function BYTE (line 101) | static BYTE product(WORD x,WORD y)
function WORD (line 109) | static WORD InvMixCol(WORD x)
function BYTE (line 126) | static BYTE ByteSub(BYTE x)
function suhosin_aes_gentables (line 137) | void suhosin_aes_gentables()
function suhosin_aes_gkey (line 184) | void suhosin_aes_gkey(int nb,int nk,char *key TSRMLS_DC)
function suhosin_aes_encrypt (line 256) | void suhosin_aes_encrypt(char *buff TSRMLS_DC)
function suhosin_aes_decrypt (line 303) | void suhosin_aes_decrypt(char *buff TSRMLS_DC)
FILE: crypt.c
function suhosin_get_ipv4 (line 31) | static void suhosin_get_ipv4(char *buf TSRMLS_DC)
FILE: ex_imp.c
function php_valid_var_name (line 45) | static int php_valid_var_name(char *var_name, int len) /* {{{ */
function PHP_FUNCTION (line 87) | PHP_FUNCTION(suhosin_extract)
function suhosin_hook_ex_imp (line 262) | void suhosin_hook_ex_imp(TSRMLS_D)
FILE: execute.c
function suhosin_check_filename (line 115) | static int suhosin_check_filename(char *s, int len TSRMLS_DC)
function suhosin_zend_stream_open (line 262) | static int suhosin_zend_stream_open(const char *filename, zend_file_hand...
function suhosin_detect_codetype (line 310) | static int suhosin_detect_codetype(zend_op_array *op_array TSRMLS_DC)
function suhosin_execute_ex (line 377) | static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dum...
function suhosin_execute (line 625) | static void suhosin_execute(zend_op_array *op_array TSRMLS_DC)
function suhosin_execute_ZO (line 632) | static void suhosin_execute_ZO(zend_op_array *op_array, long dummy TSRML...
type internal_function_handler (line 651) | typedef struct _internal_function_handler {
function ih_preg_replace (line 661) | int ih_preg_replace(IH_HANDLER_PARAMS)
function ih_symlink (line 706) | int ih_symlink(IH_HANDLER_PARAMS)
function ih_mail (line 723) | int ih_mail(IH_HANDLER_PARAMS)
function ih_querycheck (line 830) | int ih_querycheck(IH_HANDLER_PARAMS)
function ih_fixusername (line 987) | int ih_fixusername(IH_HANDLER_PARAMS)
function ih_function_exists (line 1078) | static int ih_function_exists(IH_HANDLER_PARAMS)
function suhosin_mt_initialize (line 1223) | static inline void suhosin_mt_initialize(php_uint32 seed, php_uint32 *st...
function suhosin_mt_init_by_array (line 1242) | static inline void suhosin_mt_init_by_array(php_uint32 *key, int keylen,...
function suhosin_mt_reload (line 1265) | static inline void suhosin_mt_reload(php_uint32 *state, php_uint32 **nex...
function suhosin_mt_srand (line 1285) | static void suhosin_mt_srand(php_uint32 seed TSRMLS_DC)
function php_uint32 (line 1298) | static php_uint32 suhosin_mt_rand(TSRMLS_D)
function suhosin_gen_entropy (line 1320) | static void suhosin_gen_entropy(php_uint32 *entropybuf TSRMLS_DC)
function suhosin_srand_auto (line 1370) | static void suhosin_srand_auto(TSRMLS_D)
function suhosin_mt_srand_auto (line 1385) | static void suhosin_mt_srand_auto(TSRMLS_D)
function suhosin_srand (line 1401) | static void suhosin_srand(php_uint32 seed TSRMLS_DC)
function php_uint32 (line 1414) | static php_uint32 suhosin_rand(TSRMLS_D)
function ih_srand (line 1434) | static int ih_srand(IH_HANDLER_PARAMS)
function ih_mt_srand (line 1456) | static int ih_mt_srand(IH_HANDLER_PARAMS)
function ih_mt_rand (line 1478) | static int ih_mt_rand(IH_HANDLER_PARAMS)
function ih_rand (line 1502) | static int ih_rand(IH_HANDLER_PARAMS)
function ih_getrandmax (line 1526) | static int ih_getrandmax(IH_HANDLER_PARAMS)
function suhosin_execute_internal (line 1668) | static void suhosin_execute_internal(zend_execute_data *execute_data_ptr...
function function_lookup (line 1783) | static int function_lookup(zend_extension *extension)
function suhosin_hook_execute (line 1800) | void suhosin_hook_execute(TSRMLS_D)
function suhosin_unhook_execute (line 1854) | void suhosin_unhook_execute()
FILE: header.c
function suhosin_header_handler (line 189) | int suhosin_header_handler(sapi_header_struct *sapi_header, sapi_header_...
function suhosin_hook_header_handler (line 297) | void suhosin_hook_header_handler()
function suhosin_unhook_header_handler (line 308) | void suhosin_unhook_header_handler()
FILE: ifilter.c
function strnlen (line 38) | static size_t strnlen(const char *s, size_t maxlen) {
function suhosin_strnspn (line 44) | size_t suhosin_strnspn(const char *input, size_t n, const char *accept)
function suhosin_strncspn (line 54) | size_t suhosin_strncspn(const char *input, size_t n, const char *reject)
function normalize_varname (line 67) | void normalize_varname(char *varname)
function suhosin_server_strip (line 149) | static void suhosin_server_strip(HashTable *arr, char *key, int klen)
function suhosin_server_encode (line 170) | static void suhosin_server_encode(HashTable *arr, char *key, int klen)
function suhosin_register_server_variables (line 214) | void suhosin_register_server_variables(zval *track_vars_array TSRMLS_DC)
function suhosin_input_filter_wrapper (line 289) | unsigned int suhosin_input_filter_wrapper(int arg, char *var, char **val...
function suhosin_input_filter (line 319) | unsigned int suhosin_input_filter(int arg, char *var, char **val, unsign...
function suhosin_hook_register_server_variables (line 707) | void suhosin_hook_register_server_variables()
FILE: log.c
function PHP_SUHOSIN_API (line 93) | PHP_SUHOSIN_API void suhosin_log(int loglevel, char *fmt, ...)
FILE: mbregex/mbregex.h
type mbre_register_info_type (line 100) | typedef union
type mbre_pattern_buffer (line 111) | struct mbre_pattern_buffer
type mb_regex_t (line 148) | typedef struct mbre_pattern_buffer mb_regex_t;
type mbre_registers (line 160) | struct mbre_registers
type regoff_t (line 170) | typedef size_t regoff_t;
type regmatch_t (line 175) | typedef struct
type mbre_pattern_buffer (line 185) | struct mbre_pattern_buffer
type mbre_pattern_buffer (line 186) | struct mbre_pattern_buffer
type mbre_pattern_buffer (line 188) | struct mbre_pattern_buffer
type mbre_pattern_buffer (line 189) | struct mbre_pattern_buffer
type mbre_pattern_buffer (line 190) | struct mbre_pattern_buffer
type mbre_registers (line 191) | struct mbre_registers
type mbre_pattern_buffer (line 192) | struct mbre_pattern_buffer
type mbre_registers (line 193) | struct mbre_registers
type mbre_registers (line 195) | struct mbre_registers
type mbre_registers (line 195) | struct mbre_registers
type mbre_registers (line 196) | struct mbre_registers
FILE: memory_limit.c
function PHP_INI_MH (line 35) | static PHP_INI_MH(suhosin_OnChangeMemoryLimit)
function suhosin_hook_memory_limit (line 77) | void suhosin_hook_memory_limit(TSRMLS_D)
FILE: php_suhosin.h
function suhosin_is_protected_varname (line 73) | static inline int suhosin_is_protected_varname(char *var, int var_len)
FILE: pledge.c
function PHP_FUNCTION (line 50) | static PHP_FUNCTION(suhosin_pledge)
function suhosin_hook_pledge (line 113) | void suhosin_hook_pledge(TSRMLS_D)
FILE: post_handler.c
function SAPI_POST_HANDLER_FUNC (line 45) | SAPI_POST_HANDLER_FUNC(suhosin_std_post_handler)
type post_var_data_t (line 90) | typedef struct post_var_data {
function zend_bool (line 97) | static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool...
function add_post_vars (line 151) | static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_b...
function SAPI_POST_HANDLER_FUNC (line 173) | SAPI_POST_HANDLER_FUNC(suhosin_std_post_handler)
function suhosin_post_handler_modification (line 210) | static void suhosin_post_handler_modification(sapi_post_entry *spe)
function PHP_INI_MH (line 220) | static PHP_INI_MH(suhosin_OnUpdate_mbstring_encoding_translation)
function suhosin_hook_post_handlers (line 261) | void suhosin_hook_post_handlers(TSRMLS_D)
function suhosin_unhook_post_handlers (line 288) | void suhosin_unhook_post_handlers(TSRMLS_D)
FILE: rfc1867_new.c
function dummy_encoding_translation (line 46) | static int dummy_encoding_translation(TSRMLS_D)
function normalize_protected_variable (line 79) | static void normalize_protected_variable(char *varname TSRMLS_DC) /* {{{ */
function add_protected_variable (line 137) | static void add_protected_variable(char *varname TSRMLS_DC) /* {{{ */
function zend_bool (line 146) | static zend_bool is_protected_variable(char *varname TSRMLS_DC) /* {{{ */
function safe_php_register_variable (line 153) | static void safe_php_register_variable(char *var, char *strval, int val_...
function safe_php_register_variable_ex (line 161) | static void safe_php_register_variable_ex(char *var, zval *val, zval *tr...
function register_http_post_files_variable (line 169) | static void register_http_post_files_variable(char *strvar, char *val, z...
function register_http_post_files_variable_ex (line 175) | static void register_http_post_files_variable_ex(char *var, zval *val, z...
function unlink_filename (line 181) | static int unlink_filename(char **filename TSRMLS_DC) /* {{{ */
type multipart_buffer (line 200) | typedef struct {
type mime_header_entry (line 218) | typedef struct {
function fill_buffer (line 227) | static int fill_buffer(multipart_buffer *self TSRMLS_DC)
function multipart_buffer_eof (line 263) | static int multipart_buffer_eof(multipart_buffer *self TSRMLS_DC)
function multipart_buffer (line 273) | static multipart_buffer *multipart_buffer_new(char *boundary, int bounda...
function php_free_hdr_entry (line 361) | static void php_free_hdr_entry(mime_header_entry *h)
function find_boundary (line 372) | static int find_boundary(multipart_buffer *self, char *boundary TSRMLS_DC)
function multipart_buffer_headers (line 390) | static int multipart_buffer_headers(multipart_buffer *self, zend_llist *...
function multipart_buffer_read (line 613) | static int multipart_buffer_read(multipart_buffer *self, char *buf, int ...
function SAPI_POST_HANDLER_FUNC (line 684) | SAPI_POST_HANDLER_FUNC(suhosin_rfc1867_post_handler) /* {{{ */
FILE: session.c
function suhosin_session_encode (line 58) | int suhosin_session_encode(char **newstr, int *newlen TSRMLS_DC)
function suhosin_send_cookie (line 92) | static void suhosin_send_cookie(TSRMLS_D)
function suhosin_hook_s_read (line 116) | static int suhosin_hook_s_read(void **mod_data, const char *key, char **...
function suhosin_hook_s_write (line 165) | static int suhosin_hook_s_write(void **mod_data, const char *key, const ...
function suhosin_hook_s_destroy (line 213) | static int suhosin_hook_s_destroy(void **mod_data, const char *key TSRML...
function suhosin_hook_session_module (line 230) | static void suhosin_hook_session_module(TSRMLS_D)
function PHP_INI_MH (line 260) | static PHP_INI_MH(suhosin_OnUpdateSaveHandler)
function suhosin_hook_session_RINIT (line 279) | static int suhosin_hook_session_RINIT(INIT_FUNC_ARGS)
function suhosin_hook_session (line 291) | void suhosin_hook_session(TSRMLS_D)
function suhosin_unhook_session (line 354) | void suhosin_unhook_session(TSRMLS_D)
function suhosin_hook_session (line 374) | void suhosin_hook_session(TSRMLS_D)
function suhosin_unhook_session (line 378) | void suhosin_unhook_session(TSRMLS_D)
FILE: sha256.c
function make_sha256_digest (line 29) | static void make_sha256_digest(char *sha256str, unsigned char *digest)
function PHP_FUNCTION (line 43) | static PHP_FUNCTION(suhosin_sha256)
function PHP_FUNCTION (line 73) | static PHP_FUNCTION(suhosin_sha256_file)
function suhosin_SHA256Init (line 164) | void suhosin_SHA256Init(suhosin_SHA256_CTX * context)
function suhosin_SHA256Update (line 185) | void suhosin_SHA256Update(suhosin_SHA256_CTX * context, const unsigned c...
function suhosin_SHA256Final (line 226) | void suhosin_SHA256Final(unsigned char digest[32], suhosin_SHA256_CTX * ...
function SHA256Transform (line 262) | static void SHA256Transform(state, block)
function SHA256Encode (line 355) | static void SHA256Encode(output, input, len)
function SHA256Decode (line 375) | static void SHA256Decode(output, input, len)
function suhosin_hook_sha256 (line 399) | void suhosin_hook_sha256(TSRMLS_D)
FILE: sha256.h
type suhosin_SHA256_CTX (line 28) | typedef struct {
FILE: suhosin.c
function suhosin_op_array_ctor (line 84) | static void suhosin_op_array_ctor(zend_op_array *op_array)
function suhosin_op_array_dtor (line 103) | static void suhosin_op_array_dtor(zend_op_array *op_array)
function stealth_op_array_ctor (line 112) | static void stealth_op_array_ctor(zend_op_array *op_array)
function stealth_op_array_dtor (line 120) | static void stealth_op_array_dtor(zend_op_array *op_array)
function stealth_module_startup (line 128) | static int stealth_module_startup(zend_extension *extension)
function stealth_module_shutdown (line 135) | static void stealth_module_shutdown(zend_extension *extension)
function suhosin_module_startup (line 144) | static int suhosin_module_startup(zend_extension *extension)
function suhosin_shutdown (line 193) | static void suhosin_shutdown(zend_extension *extension)
function suhosin_startup_wrapper (line 211) | static int suhosin_startup_wrapper(zend_extension *ext)
function ZEND_INI_MH (line 282) | static ZEND_INI_MH(OnUpdateSuhosin_perdir)
function ZEND_INI_MH (line 383) | static ZEND_INI_MH(OnUpdateSuhosin_log_syslog)
function ZEND_INI_MH (line 398) | static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_facility)
function ZEND_INI_MH (line 408) | static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_priority)
function ZEND_INI_MH (line 418) | static ZEND_INI_MH(OnUpdateSuhosin_log_sapi)
function ZEND_INI_MH (line 433) | static ZEND_INI_MH(OnUpdateSuhosin_log_stdout)
function ZEND_INI_MH (line 448) | static ZEND_INI_MH(OnUpdateSuhosin_log_script)
function ZEND_INI_MH (line 463) | static ZEND_INI_MH(OnUpdateSuhosin_log_scriptname)
function ZEND_INI_MH (line 475) | static ZEND_INI_MH(OnUpdateSuhosin_log_phpscript)
function ZEND_INI_MH (line 490) | static ZEND_INI_MH(OnUpdateSuhosin_log_file)
function parse_list (line 506) | static void parse_list(HashTable **ht, char *list, zend_bool lc)
function ZEND_INI_MH (line 560) | static ZEND_INI_MH(OnUpdate_include_blacklist)
function ZEND_INI_MH (line 567) | static ZEND_INI_MH(OnUpdate_include_whitelist)
function ZEND_INI_MH (line 574) | static ZEND_INI_MH(OnUpdate_func_blacklist)
function ZEND_INI_MH (line 581) | static ZEND_INI_MH(OnUpdate_func_whitelist)
function ZEND_INI_MH (line 588) | static ZEND_INI_MH(OnUpdate_eval_blacklist)
function ZEND_INI_MH (line 595) | static ZEND_INI_MH(OnUpdate_eval_whitelist)
function ZEND_INI_MH (line 603) | static ZEND_INI_MH(OnUpdate_cookie_cryptlist)
function ZEND_INI_MH (line 610) | static ZEND_INI_MH(OnUpdate_cookie_plainlist)
function ZEND_INI_MH (line 617) | static ZEND_INI_MH(OnUpdate_disable_display_errors) /* {{{ */
function ZEND_INI_MH (line 649) | static ZEND_INI_MH(OnUpdate_fail)
function PHP_FUNCTION (line 658) | static PHP_FUNCTION(suhosin_encrypt_cookie)
function PHP_FUNCTION (line 692) | static PHP_FUNCTION(suhosin_get_raw_cookies)
function suhosin_bailout (line 943) | void suhosin_bailout(TSRMLS_D)
function STATIC (line 953) | STATIC void php_suhosin_init_globals(zend_suhosin_globals *suhosin_globals)
function PHP_MINIT_FUNCTION (line 961) | PHP_MINIT_FUNCTION(suhosin)
function PHP_MSHUTDOWN_FUNCTION (line 1076) | PHP_MSHUTDOWN_FUNCTION(suhosin)
function PHP_RINIT_FUNCTION (line 1087) | PHP_RINIT_FUNCTION(suhosin)
function PHP_RSHUTDOWN_FUNCTION (line 1100) | PHP_RSHUTDOWN_FUNCTION(suhosin)
function suhosin_ini_displayer (line 1147) | static void suhosin_ini_displayer(zend_ini_entry *ini_entry, int type)
function PHP_MINFO_FUNCTION (line 1157) | PHP_MINFO_FUNCTION(suhosin)
FILE: suhosin_rfc1867.h
type multipart_event_start (line 41) | typedef struct _multipart_event_start {
type multipart_event_formdata (line 45) | typedef struct _multipart_event_formdata {
type multipart_event_file_start (line 53) | typedef struct _multipart_event_file_start {
type multipart_event_file_data (line 59) | typedef struct _multipart_event_file_data {
type multipart_event_file_end (line 67) | typedef struct _multipart_event_file_end {
type multipart_event_end (line 73) | typedef struct _multipart_event_end {
FILE: treat_data.c
function SAPI_TREAT_DATA_FUNC (line 34) | SAPI_TREAT_DATA_FUNC(suhosin_treat_data)
function suhosin_hook_treat_data (line 199) | void suhosin_hook_treat_data()
FILE: ufilter.c
function check_fileupload_varname (line 42) | static int check_fileupload_varname(char *varname TSRMLS_DC)
function suhosin_validate_utf8_multibyte (line 169) | static inline int suhosin_validate_utf8_multibyte(const char* cp, size_t...
function suhosin_rfc1867_filter (line 196) | int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **...
Condensed preview — 246 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (619K chars).
[
{
"path": ".gitignore",
"chars": 322,
"preview": ".DS_Store\n/config.log\n/config.guess\n/config.h\n/config.h.in\n/config.h.in~\n/config.nice\n/config.status\n/config.sub\n/*.lo\n/"
},
{
"path": ".travis.yml",
"chars": 340,
"preview": "language: php\nos: linux\n\nphp:\n - 5.6\n - 5.5\n - 5.4\n\nenv:\n - CC=gcc CFLAGS=\"\"\n - CC=clang CFLAGS=\"\"\n\nbefore_instal"
},
{
"path": "CREDITS",
"chars": 21,
"preview": "suhosin\nStefan Esser\n"
},
{
"path": "Changelog",
"chars": 14595,
"preview": "2016-xx-xx - 0.9.39dev2\n - some improvements for Windows (NewEraCracker)\n - fixes for test cases (NewEraCracker)\n "
},
{
"path": "LICENSE",
"chars": 3218,
"preview": "-------------------------------------------------------------------- \n The PHP License, version 3.01\nCo"
},
{
"path": "README.md",
"chars": 559,
"preview": "[](https://travis-ci.org/sektioneins/suhosin"
},
{
"path": "aes.c",
"chars": 9647,
"preview": "/* Rijndael Block Cipher - rijndael.c\n\n Written by Mike Scott 21st April 1999\n mike@compapp.dcu.ie\n An alternative"
},
{
"path": "config.m4",
"chars": 773,
"preview": "dnl $Id: config.m4,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $\ndnl config.m4 for extension suhosin\n\nPHP_ARG_ENABLE(suhosi"
},
{
"path": "config.w32",
"chars": 638,
"preview": "// $Id: config.w32,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $\n// vim:ft=javascript\n\nARG_ENABLE(\"suhosin\", \"whether to en"
},
{
"path": "crypt.c",
"chars": 7921,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "ex_imp.c",
"chars": 8187,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "execute.c",
"chars": 53926,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "header.c",
"chars": 8516,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "ifilter.c",
"chars": 22013,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "log.c",
"chars": 12426,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "mbregex/COPYING.LIB",
"chars": 26532,
"preview": "\n GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1, February 1999\n\n Copyright (C) 1"
},
{
"path": "mbregex/mbregex.h",
"chars": 7507,
"preview": "/* Definitions for data structures and routines for the regular\n expression library, version 0.12.\n Copyright (C) 19"
},
{
"path": "mbregex.h",
"chars": 1326,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "memory_limit.c",
"chars": 3331,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "php_suhosin.h",
"chars": 11812,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "pkg/build_deb.sh",
"chars": 3244,
"preview": "#!/bin/bash\n\n_exit() {\n\techo \"[E] bye.\"\n\texit 1\n}\n\nyn_or_exit() {\n\techo -n \"[?] OK? [y] \"\n\tread yn\n\tif [ \"$yn\" != \"\" -a "
},
{
"path": "pledge.c",
"chars": 3896,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "pledge.h",
"chars": 1342,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "post_handler.c",
"chars": 9170,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "rfc1867_new.c",
"chars": 36510,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "session.c",
"chars": 10943,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "sha256.c",
"chars": 13023,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "sha256.h",
"chars": 1774,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "suhosin.c",
"chars": 45271,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "suhosin.ini",
"chars": 44582,
"preview": ";extension=suhosin.so\n[suhosin]\n; \n; =====================\n; Logging Configuration\n; =====================\n; \n; suhosin."
},
{
"path": "suhosin_logo.h",
"chars": 12062,
"preview": "#define SUHOSIN_LOGO_GUID \"SUHO8567F54-D428-14d2-A769-00DA302A5F18\"\n\nstatic unsigned char suhosin_logo[] =\n\t\"\\xff\\xd8\\xf"
},
{
"path": "suhosin_rfc1867.h",
"chars": 2935,
"preview": "/*\n +----------------------------------------------------------------------+\n | Suhosin Version 1 "
},
{
"path": "tests/cookie/crypt.checkraddr_4.phpt",
"chars": 518,
"preview": "--TEST--\ncookie encryption with checkraddr=4\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encrypt"
},
{
"path": "tests/cookie/crypt.checkraddr_4_incorrect.phpt",
"chars": 488,
"preview": "--TEST--\ncookie encryption with checkraddr=4\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encrypt"
},
{
"path": "tests/cookie/crypt.cryptlist.phpt",
"chars": 637,
"preview": "--TEST--\ncookie encryption with cryptlist set\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encryp"
},
{
"path": "tests/cookie/crypt.docroot.phpt",
"chars": 585,
"preview": "--TEST--\ncookie encryption using document root\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encry"
},
{
"path": "tests/cookie/crypt.invalid.phpt",
"chars": 450,
"preview": "--TEST--\ncookie encryption with invalid cookie\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encry"
},
{
"path": "tests/cookie/crypt.key_default.phpt",
"chars": 536,
"preview": "--TEST--\ncookie encryption with default key\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encrypt="
},
{
"path": "tests/cookie/crypt.key_empty.phpt",
"chars": 527,
"preview": "--TEST--\ncookie encryption with empty key\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encrypt=1\n"
},
{
"path": "tests/cookie/crypt.key_empty_remote_addr.phpt",
"chars": 596,
"preview": "--TEST--\ncookie encryption with empty key and REMOTE_ADDR set\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhos"
},
{
"path": "tests/cookie/crypt.no_encryption.phpt",
"chars": 289,
"preview": "--TEST--\ncookie without encryption\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encrypt=0\n--COOKI"
},
{
"path": "tests/cookie/crypt.plainlist.phpt",
"chars": 638,
"preview": "--TEST--\ncookie encryption with plainlist set\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cookie.encryp"
},
{
"path": "tests/cookie/crypt.raddr_1.phpt",
"chars": 598,
"preview": "--TEST--\ncookie encryption using REMOTE_ADDR (cryptraddr=1)\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/cookie/crypt.raddr_2.phpt",
"chars": 598,
"preview": "--TEST--\ncookie encryption using REMOTE_ADDR (cryptraddr=2)\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/cookie/crypt.raddr_3.phpt",
"chars": 598,
"preview": "--TEST--\ncookie encryption using REMOTE_ADDR (cryptraddr=3)\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/cookie/crypt.raddr_4.phpt",
"chars": 598,
"preview": "--TEST--\ncookie encryption using REMOTE_ADDR (cryptraddr=4)\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/cookie/crypt.ua.phpt",
"chars": 588,
"preview": "--TEST--\ncookie with encryption using HTTP_USER_AGENT\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.cooki"
},
{
"path": "tests/empty.inc",
"chars": 43,
"preview": "<?php\n $value = \"value-from-empty.inc\";\n?>"
},
{
"path": "tests/executor/allow_symlink_off.phpt",
"chars": 695,
"preview": "--TEST--\nsuhosin.executor.allow_symlink=Off\n--SKIPIF--\n<?php if (!function_exists(\"memory_get_usage\")) print \"skip PHP n"
},
{
"path": "tests/executor/allow_symlink_on.phpt",
"chars": 553,
"preview": "--TEST--\nsuhosin.executor.allow_symlink=On\n--SKIPIF--\n<?php if (!function_exists(\"memory_get_usage\")) print \"skip PHP no"
},
{
"path": "tests/executor/disable_emod_off.phpt",
"chars": 484,
"preview": "--TEST--\nTesting: suhosin.executor.disable_emodifier=0\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nerror_"
},
{
"path": "tests/executor/disable_emod_on.phpt",
"chars": 714,
"preview": "--TEST--\nTesting: suhosin.executor.disable_emodifier=1\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nerror_"
},
{
"path": "tests/executor/disable_eval_off.phpt",
"chars": 249,
"preview": "--TEST--\nTesting: suhosin.executor.disable_eval=0\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log"
},
{
"path": "tests/executor/disable_eval_on.phpt",
"chars": 446,
"preview": "--TEST--\nTesting: suhosin.executor.disable_eval=1\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log"
},
{
"path": "tests/executor/eval_blacklist.phpt",
"chars": 461,
"preview": "--TEST--\nTesting: suhosin.executor.eval.blacklist=max\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/executor/eval_blacklist_printf.phpt",
"chars": 517,
"preview": "--TEST--\nTesting: suhosin.executor.eval.blacklist=printf via call_user_func\n--SKIPIF--\n<?php include \"../skipifnotcli.in"
},
{
"path": "tests/executor/eval_blacklist_printf_function_exists.phpt",
"chars": 545,
"preview": "--TEST--\nTesting: suhosin.executor.eval.blacklist=printf with function_exists()\n--SKIPIF--\n<?php include \"../skipifnotcl"
},
{
"path": "tests/executor/eval_whitelist_absmax.phpt",
"chars": 278,
"preview": "--TEST--\nTesting: suhosin.executor.eval.whitelist=abs,max\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuh"
},
{
"path": "tests/executor/eval_whitelist_call_user_func.phpt",
"chars": 497,
"preview": "--TEST--\nTesting: suhosin.executor.eval.whitelist=printf via call_user_func\n--SKIPIF--\n<?php include \"../skipifnotcli.in"
},
{
"path": "tests/executor/function_blacklist.phpt",
"chars": 399,
"preview": "--TEST--\nTesting: suhosin.executor.func.blacklist=max\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/executor/function_blacklist_printf.phpt",
"chars": 420,
"preview": "--TEST--\nTesting: suhosin.executor.func.blacklist=printf\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuho"
},
{
"path": "tests/executor/function_blacklist_printf_function_exists.phpt",
"chars": 468,
"preview": "--TEST--\nTesting: suhosin.executor.func.blacklist=printf with function_exists()\n--SKIPIF--\n<?php include \"../skipifnotcl"
},
{
"path": "tests/executor/function_call_user_func.phpt",
"chars": 204,
"preview": "--TEST--\nTesting if call_user_func() actually works\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.l"
},
{
"path": "tests/executor/function_whitelist.phpt",
"chars": 403,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist=abs\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/executor/function_whitelist_absmax.phpt",
"chars": 237,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist=abs,max\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuh"
},
{
"path": "tests/executor/function_whitelist_call_user_func.phpt",
"chars": 440,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist=call_user_func\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--IN"
},
{
"path": "tests/executor/function_whitelist_function_exists.phpt",
"chars": 487,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist with function_exists()\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\";"
},
{
"path": "tests/executor/function_whitelist_maxabs.phpt",
"chars": 237,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist=max,abs\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuh"
},
{
"path": "tests/executor/function_whitelist_without_function_exists.phpt",
"chars": 615,
"preview": "--TEST--\nTesting: suhosin.executor.func.whitelist without function_exists()\n--SKIPIF--\n<?php include \"../skipifnotcli.in"
},
{
"path": "tests/executor/memory_limit.phpt",
"chars": 1080,
"preview": "--TEST--\nmemory_limit test: set suhosin hard_limit to normal limit\n--SKIPIF--\n<?php if (!function_exists(\"memory_get_usa"
},
{
"path": "tests/executor/memory_limit_64bit.phpt",
"chars": 2066,
"preview": "--TEST--\nmemory_limit test: set suhosin hard_limit to normal limit (64 bit)\n--SKIPIF--\n<?php if (!function_exists(\"memor"
},
{
"path": "tests/executor/memory_limit_64bit_10G.phpt",
"chars": 1165,
"preview": "--TEST--\nmemory_limit test: set suhosin hard_limit to normal limit (64 bit) - 10 GB\n--SKIPIF--\n<?php if (!function_exist"
},
{
"path": "tests/executor/memory_limit_negative.phpt",
"chars": 578,
"preview": "--TEST--\nmemory_limit test: trying to set memory_limit to a negative value\n--SKIPIF--\n<?php if (!function_exists(\"memory"
},
{
"path": "tests/executor/memory_limit_other_hardlimit.phpt",
"chars": 932,
"preview": "--TEST--\nmemory_limit test: set suhosin hard_limit to normal limit + 1M\n--SKIPIF--\n<?php if (!function_exists(\"memory_ge"
},
{
"path": "tests/executor/preg_replace.phpt",
"chars": 927,
"preview": "--TEST--\nTesting protection against \"\\0\" in preg_replace() first parameter\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n"
},
{
"path": "tests/executor/preg_replace_error.phpt",
"chars": 1222,
"preview": "--TEST--\nTesting protection against \"\\0\" in preg_replace() first parameter (INCL. SUHOSIN ERROR MESSAGES)\n--SKIPIF--\n<?p"
},
{
"path": "tests/executor/recursion_maxdepth.phpt",
"chars": 413,
"preview": "--TEST--\nTesting: suhosin.executor.max_depth\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log.sapi"
},
{
"path": "tests/executor/user_session_handler.phpt",
"chars": 1711,
"preview": "--TEST--\nTesting user session handler functions\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log.s"
},
{
"path": "tests/filter/cookie_disallow_nul.phpt",
"chars": 943,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.disallow_nul)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/cookie_disallow_ws.phpt",
"chars": 912,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.disallow_ws)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.s"
},
{
"path": "tests/filter/cookie_max_array_depth.phpt",
"chars": 1432,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_array_depth)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.l"
},
{
"path": "tests/filter/cookie_max_array_index_length.phpt",
"chars": 1480,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_array_index_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsu"
},
{
"path": "tests/filter/cookie_max_name_length.phpt",
"chars": 1248,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_name_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.l"
},
{
"path": "tests/filter/cookie_max_totalname_length.phpt",
"chars": 1168,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_totalname_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuho"
},
{
"path": "tests/filter/cookie_max_value_length.phpt",
"chars": 1149,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_value_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin."
},
{
"path": "tests/filter/cookie_max_vars.phpt",
"chars": 769,
"preview": "--TEST--\nsuhosin input filter (suhosin.cookie.max_vars)\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.log"
},
{
"path": "tests/filter/filter_action_302.phpt",
"chars": 417,
"preview": "--TEST--\nsuhosin filter action: 302 redirect\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.stdout=0\nsuhosi"
},
{
"path": "tests/filter/filter_action_php.phpt",
"chars": 392,
"preview": "--TEST--\nsuhosin filter action: fallback PHP file\n--FOO--\n<?php die(\"FALLBACK\\n\"); ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/filter/filter_logging_statistics.phpt",
"chars": 988,
"preview": "--TEST--\nsuhosin variable filter logging statistics\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script=0"
},
{
"path": "tests/filter/get_allow_ws.phpt",
"chars": 900,
"preview": "--TEST--\nsuhosin input filter (allow whitespace)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.stdout=255\n"
},
{
"path": "tests/filter/get_disallow_nul.phpt",
"chars": 928,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.disallow_nul)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.scr"
},
{
"path": "tests/filter/get_disallow_ws.phpt",
"chars": 999,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.disallow_ws)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.scri"
},
{
"path": "tests/filter/get_filter_1.phpt",
"chars": 3152,
"preview": "--TEST--\nsuhosin GET filter (disallowed variable names)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.scri"
},
{
"path": "tests/filter/get_filter_2.phpt",
"chars": 849,
"preview": "--TEST--\nsuhosin GET filter (suhosin.get.max_vars)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script=0\n"
},
{
"path": "tests/filter/get_globals.phpt",
"chars": 443,
"preview": "--TEST--\nTesting: GLOBALS in GET\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.lo"
},
{
"path": "tests/filter/get_max_array_depth.phpt",
"chars": 1417,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.max_array_depth)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/get_max_array_index_length.phpt",
"chars": 1461,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.max_array_index_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhos"
},
{
"path": "tests/filter/get_max_name_length.phpt",
"chars": 1230,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.max_name_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/get_max_totalname_length.phpt",
"chars": 1153,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.max_totalname_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin"
},
{
"path": "tests/filter/get_max_value_length.phpt",
"chars": 1131,
"preview": "--TEST--\nsuhosin input filter (suhosin.get.max_value_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log"
},
{
"path": "tests/filter/input_filter_request_max_value_length.phpt",
"chars": 2286,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.max_value_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin"
},
{
"path": "tests/filter/post_disallow_nul.phpt",
"chars": 933,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.disallow_nul)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.sc"
},
{
"path": "tests/filter/post_disallow_ws.phpt",
"chars": 1005,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.disallow_ws)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.scr"
},
{
"path": "tests/filter/post_fileupload_array_index_blacklist.phpt",
"chars": 1207,
"preview": "--TEST--\nsuhosin file upload filter (array index whitelist)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/post_fileupload_array_index_whitelist.phpt",
"chars": 1234,
"preview": "--TEST--\nsuhosin file upload filter (array index whitelist)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/post_fileupload_filter_1.phpt",
"chars": 5105,
"preview": "--TEST--\nsuhosin rfc1867 file upload filter (disallowed variable names)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\n"
},
{
"path": "tests/filter/post_fileupload_filter_2.phpt",
"chars": 1768,
"preview": "--TEST--\nsuhosin rfc1867 file upload filter (suhosin.post.max_vars)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuho"
},
{
"path": "tests/filter/post_filter_1.phpt",
"chars": 3171,
"preview": "--TEST--\nsuhosin POST filter (disallowed variable names)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.scr"
},
{
"path": "tests/filter/post_filter_2.phpt",
"chars": 855,
"preview": "--TEST--\nsuhosin POST filter (suhosin.post.max_vars)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script="
},
{
"path": "tests/filter/post_filter_empty_avar.phpt",
"chars": 381,
"preview": "--TEST--\nsuhosin POST filter with empty array variable\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.stdou"
},
{
"path": "tests/filter/post_filter_empty_var.phpt",
"chars": 340,
"preview": "--TEST--\nsuhosin POST filter with empty variable\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.stdout=255\n"
},
{
"path": "tests/filter/post_max_array_depth.phpt",
"chars": 1422,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_array_depth)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log"
},
{
"path": "tests/filter/post_max_array_depth_rfc1867.phpt",
"chars": 2199,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_array_depth - RFC1867 version)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log."
},
{
"path": "tests/filter/post_max_array_index_length.phpt",
"chars": 1467,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_array_index_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuho"
},
{
"path": "tests/filter/post_max_array_index_length_rfc1867.phpt",
"chars": 2359,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_array_index_length - RFC1867 version)\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/filter/post_max_name_length.phpt",
"chars": 1236,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_name_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log"
},
{
"path": "tests/filter/post_max_name_length_rfc1867.phpt",
"chars": 2112,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_name_length - RFC1867 version)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log."
},
{
"path": "tests/filter/post_max_totalname_length.phpt",
"chars": 1157,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_totalname_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosi"
},
{
"path": "tests/filter/post_max_totalname_length_rfc1867.phpt",
"chars": 2033,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_totalname_length - RFC1867 version)\n--INI--\nsuhosin.log.syslog=0\nsuhosin"
},
{
"path": "tests/filter/post_max_value_length.phpt",
"chars": 1137,
"preview": "--TEST--\nsuhosin input filter (suhosin.post.max_value_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.lo"
},
{
"path": "tests/filter/request_array_index_blacklist.phpt",
"chars": 1818,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.array_index_blacklist)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsu"
},
{
"path": "tests/filter/request_array_index_whitelist.phpt",
"chars": 1771,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.array_index_whitelist)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsu"
},
{
"path": "tests/filter/request_disallow_nul.phpt",
"chars": 1695,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.disallow_nul)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log"
},
{
"path": "tests/filter/request_disallow_ws.phpt",
"chars": 1019,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.disallow_ws)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log."
},
{
"path": "tests/filter/request_max_array_depth.phpt",
"chars": 3141,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.max_array_depth)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin."
},
{
"path": "tests/filter/request_max_array_index_length.phpt",
"chars": 3239,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.max_array_index_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\ns"
},
{
"path": "tests/filter/request_max_name_length.phpt",
"chars": 2587,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.max_varname_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhos"
},
{
"path": "tests/filter/request_max_totalname_length.phpt",
"chars": 2312,
"preview": "--TEST--\nsuhosin input filter (suhosin.request.max_totalname_length)\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuh"
},
{
"path": "tests/filter/server_encode_off.phpt",
"chars": 614,
"preview": "--TEST--\nTesting: suhosin.server.encode=Off\n--DESCRIPTION--\nThis test is incomplete but at the moment we cannot do bette"
},
{
"path": "tests/filter/server_encode_on.phpt",
"chars": 631,
"preview": "--TEST--\nTesting: suhosin.server.encode=On\n--DESCRIPTION--\nThis test is incomplete but at the moment we cannot do better"
},
{
"path": "tests/filter/server_filter.phpt",
"chars": 888,
"preview": "--TEST--\nsuhosin SERVER filter\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script=0\nsuhosin.log.file=255"
},
{
"path": "tests/filter/server_strip_off.phpt",
"chars": 592,
"preview": "--TEST--\nTesting: suhosin.server.strip=Off\n--DESCRIPTION--\nThis test is incomplete but at the moment we cannot do better"
},
{
"path": "tests/filter/server_strip_on.phpt",
"chars": 590,
"preview": "--TEST--\nTesting: suhosin.server.strip=On\n--DESCRIPTION--\nThis test is incomplete but at the moment we cannot do better "
},
{
"path": "tests/filter/server_user_agent_strip_off.phpt",
"chars": 668,
"preview": "--TEST--\nTesting: suhosin.server.strip=On\n--DESCRIPTION--\nThis test is not exactly what we want, but good enough due to "
},
{
"path": "tests/filter/server_user_agent_strip_on.phpt",
"chars": 667,
"preview": "--TEST--\nTesting: suhosin.server.strip=On\n--DESCRIPTION--\nThis test is not exactly what we want, but good enough due to "
},
{
"path": "tests/filter/suhosin_upload_disallow_binary_utf8.phpt",
"chars": 853,
"preview": "--TEST--\nTesting: suhosin.upload.disallow_binary=On with UTF-8\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.l"
},
{
"path": "tests/filter/suhosin_upload_disallow_binary_utf8fail.phpt",
"chars": 1090,
"preview": "--TEST--\nTesting: suhosin.upload.disallow_binary=On with UTF-8 and allow_utf8=Off\n--INI--\nsuhosin.log.syslog=0\nsuhosin.l"
},
{
"path": "tests/filter/suhosin_upload_disallow_elf.phpt",
"chars": 1343,
"preview": "--TEST--\nTesting: suhosin.upload.disallow_elf=On\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script=0\nsu"
},
{
"path": "tests/filter/suhosin_upload_disallow_elf_off.phpt",
"chars": 1128,
"preview": "--TEST--\nTesting: suhosin.upload.disallow_elf=Off\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.stdout=255"
},
{
"path": "tests/filter/suhosin_upload_max_uploads.phpt",
"chars": 1857,
"preview": "--TEST--\nsuhosin.upload.max_uploads\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log.script=0\nsuhosin.log.fil"
},
{
"path": "tests/filter/suhosin_upload_remove_binary_utf8.phpt",
"chars": 747,
"preview": "--TEST--\nTesting: suhosin.upload.remove_binary=On with UTF-8\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi=0\nsuhosin.log"
},
{
"path": "tests/filter/suhosin_upload_remove_binary_utf8fail.phpt",
"chars": 765,
"preview": "--TEST--\nTesting: suhosin.upload.remove_binary=On with UTF-8 and allow_utf8=Off\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log"
},
{
"path": "tests/funcs/crypt_blowfish.phpt",
"chars": 278,
"preview": "--TEST--\nCRYPT_BLOWFISH support\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--FILE--\n<?php\n var_dump(CRYPT_BLOWFISH)"
},
{
"path": "tests/funcs/crypt_ext_des.phpt",
"chars": 193,
"preview": "--TEST--\nCRYPT_EXT_DES support\n--SKIPIF--\n<?php if (CRYPT_EXT_DES == 0) print 'skip'; ?>\n--FILE--\n<?php\n echo crypt('"
},
{
"path": "tests/funcs/crypt_md5.phpt",
"chars": 201,
"preview": "--TEST--\nCRYPT_MD5 support\n--SKIPIF--\n<?php if (CRYPT_MD5 == 0) print 'skip'; ?>\n--FILE--\n<?php\n echo crypt('rasmusle"
},
{
"path": "tests/funcs/crypt_std_des.phpt",
"chars": 178,
"preview": "--TEST--\nCRYPT_STD_DES support\n--SKIPIF--\n<?php if (CRYPT_STD_DES == 0) print 'skip'; ?>\n--FILE--\n<?php\n echo crypt('"
},
{
"path": "tests/funcs/sha256.phpt",
"chars": 1950,
"preview": "--TEST--\nSHA256 support\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--FILE--\n<?php\n echo sha256(\"\") , \"\\n\";\n echo"
},
{
"path": "tests/include/include_allow_writable_files_off.phpt",
"chars": 1036,
"preview": "--TEST--\nTesting suhosin.executor.include.allow_writable_files=Off\n--DESCRIPTION--\nBecause the test file itself is writa"
},
{
"path": "tests/include/include_allow_writable_files_on.phpt",
"chars": 759,
"preview": "--TEST--\nTesting suhosin.executor.include.allow_writable_files=On\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI-"
},
{
"path": "tests/include/include_blacklist.phpt",
"chars": 657,
"preview": "--TEST--\nInclude blacklist\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi"
},
{
"path": "tests/include/include_blackwhitelist_empty.phpt",
"chars": 645,
"preview": "--TEST--\nInclude URL with empty black-/whitelist\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.sys"
},
{
"path": "tests/include/include_constant.phpt",
"chars": 439,
"preview": "--TEST--\nInclude \"Constant URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.lo"
},
{
"path": "tests/include/include_etc_passwd.phpt",
"chars": 694,
"preview": "--TEST--\nInclude \"../../../../../../../../../../../etc/passwd\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\n"
},
{
"path": "tests/include/include_max_traversal.phpt",
"chars": 1169,
"preview": "--TEST--\nTesting suhosin.executor.include.max_traversal=10\n--DESCRIPTION--\nSeems to work fine, maybe split up later into"
},
{
"path": "tests/include/include_nul_in_filename.phpt",
"chars": 617,
"preview": "--TEST--\nTesting include of filename including ASCIIZ character\n--DESCRIPTION--\n\nThis test will only trigger the PHP int"
},
{
"path": "tests/include/include_once_constant.phpt",
"chars": 449,
"preview": "--TEST--\nInclude_once \"Constant URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/include_once_tmpvar.phpt",
"chars": 493,
"preview": "--TEST--\nInclude_once \"Temp Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\n"
},
{
"path": "tests/include/include_once_var.phpt",
"chars": 466,
"preview": "--TEST--\nInclude_once \"Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/include_tmpvar.phpt",
"chars": 483,
"preview": "--TEST--\nInclude \"Temp Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/include_too_long.phpt",
"chars": 462,
"preview": "--TEST--\nTesting include of too long filename\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog"
},
{
"path": "tests/include/include_uploaded_file_diff_filename.phpt",
"chars": 778,
"preview": "--TEST--\nTesting include file from $_FILES (but change name a bit)\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI"
},
{
"path": "tests/include/include_uploaded_file_from_FILES.phpt",
"chars": 739,
"preview": "--TEST--\nTesting include file from $_FILES\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\n"
},
{
"path": "tests/include/include_var.phpt",
"chars": 456,
"preview": "--TEST--\nInclude \"Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.lo"
},
{
"path": "tests/include/include_whitelist.phpt",
"chars": 639,
"preview": "--TEST--\nInclude whitelist\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.log.sapi"
},
{
"path": "tests/include/require_constant.phpt",
"chars": 439,
"preview": "--TEST--\nRequire \"Constant URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.lo"
},
{
"path": "tests/include/require_once_constant.phpt",
"chars": 449,
"preview": "--TEST--\nRequire_once \"Constant URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/require_once_tmpvar.phpt",
"chars": 493,
"preview": "--TEST--\nRequire_once \"Temp Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\n"
},
{
"path": "tests/include/require_once_var.phpt",
"chars": 466,
"preview": "--TEST--\nRequire_once \"Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/require_tmpvar.phpt",
"chars": 483,
"preview": "--TEST--\nRequire \"Temp Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhos"
},
{
"path": "tests/include/require_var.phpt",
"chars": 456,
"preview": "--TEST--\nRequire \"Variable URL\";\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.log.syslog=0\nsuhosin.lo"
},
{
"path": "tests/logging/log_max_error_length.phpt",
"chars": 474,
"preview": "--TEST--\nTesting: suhosin.log.use-x-forwarded-for=On (without X-Forwarded-For set)\n--SKIPIF--\n<?php include \"../skipifno"
},
{
"path": "tests/logging/logscript_executable.phpt",
"chars": 376,
"preview": "--TEST--\nTesting: suhosin.log.script.name=EXECUTABLE\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin."
},
{
"path": "tests/logging/logscript_nonexecutable.phpt",
"chars": 509,
"preview": "--TEST--\nTesting: suhosin.log.script.name=NON-EXECUTABLE\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuho"
},
{
"path": "tests/logging/logscript_nonexistant.phpt",
"chars": 572,
"preview": "--TEST--\nTesting: suhosin.log.script.name=NON-EXISTANT\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosi"
},
{
"path": "tests/logging/use_x_forwarded_for_off.phpt",
"chars": 723,
"preview": "--TEST--\nTesting: suhosin.log.use-x-forwarded-for=Off\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/logging/use_x_forwarded_for_off_no_remote_addr.phpt",
"chars": 669,
"preview": "--TEST--\nTesting: suhosin.log.use-x-forwarded-for=Off (without REMOTE_ADDR set)\n--SKIPIF--\n<?php include \"../skipifnotcl"
},
{
"path": "tests/logging/use_x_forwarded_for_on.phpt",
"chars": 713,
"preview": "--TEST--\nTesting: suhosin.log.use-x-forwarded-for=On\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin."
},
{
"path": "tests/logging/use_x_forwarded_for_on_no_x_forwarded.phpt",
"chars": 675,
"preview": "--TEST--\nTesting: suhosin.log.use-x-forwarded-for=On (without X-Forwarded-For set)\n--SKIPIF--\n<?php include \"../skipifno"
},
{
"path": "tests/misc/disable_display_errors_fail.phpt",
"chars": 663,
"preview": "--TEST--\nTesting: suhosin.disable.display_errors=fail\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin"
},
{
"path": "tests/misc/disable_display_errors_off.phpt",
"chars": 890,
"preview": "--TEST--\nTesting: suhosin.disable.display_errors=Off\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin."
},
{
"path": "tests/misc/disable_display_errors_on.phpt",
"chars": 743,
"preview": "--TEST--\nTesting: suhosin.disable.display_errors=On\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.l"
},
{
"path": "tests/misc/mailprotect_1_header_nl.phpt",
"chars": 544,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 and extra headers start with newline\n--SKIPIF--\n<?php include \"../skipifnotcli."
},
{
"path": "tests/misc/mailprotect_1_header_nlnl.phpt",
"chars": 566,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 and extra headers contain double newline\n--SKIPIF--\n<?php include \"../skipifnot"
},
{
"path": "tests/misc/mailprotect_1_subject.phpt",
"chars": 512,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 with NL in Subject\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\ns"
},
{
"path": "tests/misc/mailprotect_1_subject_long.phpt",
"chars": 398,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 with valid long Subject\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--IN"
},
{
"path": "tests/misc/mailprotect_1_to.phpt",
"chars": 504,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 with NL in To\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosi"
},
{
"path": "tests/misc/mailprotect_1_to_long.phpt",
"chars": 396,
"preview": "--TEST--\nTesting: suhosin.mail.protect=1 with valid long To\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\ns"
},
{
"path": "tests/misc/mailprotect_2_bcc.phpt",
"chars": 527,
"preview": "--TEST--\nTesting: suhosin.mail.protect=2 and extra headers contain Bcc:\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; "
},
{
"path": "tests/misc/mailprotect_2_cc.phpt",
"chars": 524,
"preview": "--TEST--\nTesting: suhosin.mail.protect=2 and extra headers contain Cc:\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?"
},
{
"path": "tests/misc/mailprotect_2_to.phpt",
"chars": 524,
"preview": "--TEST--\nTesting: suhosin.mail.protect=2 and extra headers contain To:\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?"
},
{
"path": "tests/misc/mt_srand_ignore_off.phpt",
"chars": 343,
"preview": "--TEST--\nTesting: suhosin.mt_srand.ignore=0\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.log.sapi=255\nsu"
},
{
"path": "tests/misc/mt_srand_ignore_on.phpt",
"chars": 343,
"preview": "--TEST--\nTesting: suhosin.mt_srand.ignore=1\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.log.sapi=255\nsu"
},
{
"path": "tests/misc/protectkey_off.phpt",
"chars": 679,
"preview": "--TEST--\nTesting: suhosin.protectkey=On\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log.sapi=0\nsu"
},
{
"path": "tests/misc/protectkey_on.phpt",
"chars": 676,
"preview": "--TEST--\nTesting: suhosin.protectkey=On\n--SKIPIF--\n<?php include \"../skipifnotcli.inc\"; ?>\n--INI--\nsuhosin.log.sapi=0\nsu"
},
{
"path": "tests/misc/srand_ignore_off.phpt",
"chars": 325,
"preview": "--TEST--\nTesting: suhosin.srand.ignore=0\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.log.sapi=255\nsuhos"
},
{
"path": "tests/misc/srand_ignore_on.phpt",
"chars": 325,
"preview": "--TEST--\nTesting: suhosin.srand.ignore=1\n--SKIPIF--\n<?php include \"../skipif.inc\"; ?>\n--INI--\nsuhosin.log.sapi=255\nsuhos"
},
{
"path": "tests/session/PHPSESSID_max_id_length_ok.phpt",
"chars": 319,
"preview": "--TEST--\nPHPSESSID session id not too long\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.session.max_i"
},
{
"path": "tests/session/PHPSESSID_max_id_length_toolong.phpt",
"chars": 294,
"preview": "--TEST--\nPHPSESSID session id too long\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--INI--\nsuhosin.session.max_id_le"
},
{
"path": "tests/session/crypt.checkraddr_4.phpt",
"chars": 519,
"preview": "--TEST--\nsession encryption with checkraddr=4\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n--ENV--\nreturn <<<END\nREMO"
},
{
"path": "tests/session/crypt.checkraddr_4_incorrect.phpt",
"chars": 519,
"preview": "--TEST--\nsession encryption with checkraddr=4 and incorrect REMOTE_ADDR\n--SKIPIF--\n<?php include \"../skipifcli.inc\"; ?>\n"
}
]
// ... and 46 more files (download for full content)
About this extraction
This page contains the full source code of the stefanesser/suhosin GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 246 files (550.3 KB), approximately 177.9k tokens, and a symbol index with 186 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.