pastebin - collaborative debugging tool
kpaste.net RSS


Suhosin 0.9.33 for PHP 5.4
Posted by Anonymous on Fri 9th Mar 2012 18:09
raw | new post
view followups (newest first): Suhosin 0.9.33 for PHP 5.4 by Anonymous

  1. --- a/execute.c
  2. +++ b/execute.c
  3. @@ -35,6 +35,7 @@
  4.  #include "zend_compile.h"
  5.  #include "zend_llist.h"
  6.  #include "SAPI.h"
  7. +#include "main/php_version.h"
  8.  
  9.  #include "sha256.h"
  10.  
  11. @@ -1031,7 +1032,9 @@
  12.  
  13.         if ((str_length == sizeof("</head>\n")-1) && (strcmp(str, "</head>\n")==0)) {
  14.                 SUHOSIN_G(old_php_body_write)(S_META_ROBOTS, sizeof(S_META_ROBOTS)-1 TSRMLS_CC);
  15. +#if PHP_VERSION_ID < 50400
  16.                 OG(php_body_write) = SUHOSIN_G(old_php_body_write);
  17. +#endif
  18.                 return SUHOSIN_G(old_php_body_write)(str, str_length TSRMLS_CC);
  19.         } else if ((str_length == sizeof(P_META_ROBOTS)-1) && (strcmp(str, P_META_ROBOTS)==0)) {
  20.                 return str_length;
  21. @@ -1054,6 +1057,7 @@
  22.         }
  23.  
  24.         /* Andale!  Andale!  Yee-Hah! */
  25. +#if PHP_VERSION_ID < 50400
  26.         php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
  27.         if (!sapi_module.phpinfo_as_text) {
  28.                 SUHOSIN_G(old_php_body_write) = OG(php_body_write);
  29. @@ -1061,6 +1065,11 @@
  30.         }
  31.         php_print_info(flag TSRMLS_CC);
  32.         php_end_ob_buffer(1, 0 TSRMLS_CC);
  33. +#else
  34. +       php_output_start_default(TSRMLS_CC);
  35. +       php_print_info(flag TSRMLS_CC);
  36. +       php_output_end();
  37. +#endif
  38.  
  39.         RETVAL_TRUE;
  40.         return (1);
  41. @@ -1606,8 +1615,14 @@
  42.         }
  43.        
  44.  #ifdef ZEND_ENGINE_2  
  45. +
  46. +#if PHP_VERSION_ID < 50400
  47.         return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.u.var)).var.ptr;
  48.  #else
  49. +       return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->extended_value)).var.ptr;
  50. +#endif
  51. +
  52. +#else
  53.          return_value = execute_data_ptr->Ts[execute_data_ptr->opline->result.u.var].var.ptr;
  54.  #endif
  55.         ht = execute_data_ptr->opline->extended_value;
  56. --- a/rfc1867.c
  57. +++ b/rfc1867.c
  58. @@ -35,6 +35,7 @@
  59.  #include "suhosin_rfc1867.h"
  60.  #include "php_ini.h"
  61.  #include "ext/standard/php_string.h"
  62. +#include "main/php_version.h"
  63.  
  64.  #define DEBUG_FILE_UPLOAD ZEND_DEBUG
  65.  
  66. @@ -244,21 +245,29 @@
  67.  
  68.  static void register_http_post_files_variable(char *strvar, char *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC)
  69.  {
  70. +#if PHP_VERSION_ID < 50400
  71.         int register_globals = PG(register_globals);
  72.  
  73.         PG(register_globals) = 0;
  74. +#endif
  75.         safe_php_register_variable(strvar, val, http_post_files, override_protection TSRMLS_CC);
  76. +#if PHP_VERSION_ID < 50400
  77.         PG(register_globals) = register_globals;
  78. +#endif
  79.  }
  80.  
  81.  
  82.  static void register_http_post_files_variable_ex(char *var, zval *val, zval *http_post_files, zend_bool override_protection TSRMLS_DC)
  83.  {
  84. +#if PHP_VERSION_ID < 50400
  85.         int register_globals = PG(register_globals);
  86.  
  87.         PG(register_globals) = 0;
  88. +#endif
  89.         safe_php_register_variable_ex(var, val, http_post_files, override_protection TSRMLS_CC);
  90. +#if PHP_VERSION_ID < 50400
  91.         PG(register_globals) = register_globals;
  92. +#endif
  93.  }
  94.  
  95.  /*
  96. --- a/session.c
  97. +++ b/session.c
  98. @@ -33,6 +33,7 @@
  99.  #include "ext/standard/php_smart_str.h"
  100.  #include "ext/standard/php_var.h"
  101.  #include "sha256.h"
  102. +#include "main/php_version.h"
  103.  
  104.  #include <fcntl.h>
  105.  
  106. @@ -294,6 +295,7 @@
  107.      if (SESSION_G(http_session_vars) && SESSION_G(http_session_vars)->type == IS_ARRAY) {
  108.          ret = zend_hash_find(Z_ARRVAL_P(SESSION_G(http_session_vars)), name, namelen + 1, (void **) state_var);
  109.  
  110. +#if PHP_VERSION_ID < 50400
  111.          /* If register_globals is enabled, and
  112.           * if there is an entry for the slot in $_SESSION, and
  113.           * if that entry is still set to NULL, and
  114. @@ -307,6 +309,7 @@
  115.                  *state_var = tmp;
  116.              }
  117.          }
  118. +#endif
  119.      }
  120.      return ret;
  121.  }
  122. --- a/log.c
  123. +++ b/log.c
  124. @@ -31,6 +31,7 @@
  125.  #include "SAPI.h"
  126.  #include "ext/standard/datetime.h"
  127.  #include "ext/standard/flock_compat.h"
  128. +#include "main/php_version.h"
  129.  
  130.  #ifdef HAVE_SYS_SOCKET_H
  131.  #include <sys/socket.h>
  132. @@ -317,7 +318,9 @@
  133.                 zval *result = NULL;
  134.                
  135.                 long orig_execution_depth = SUHOSIN_G(execution_depth);
  136. +#if PHP_VERSION_ID < 50400
  137.                 zend_bool orig_safe_mode = PG(safe_mode);
  138. +#endif
  139.                 char *orig_basedir = PG(open_basedir);
  140.                
  141.                 char *phpscript = SUHOSIN_G(log_phpscriptname);
  142. @@ -354,14 +357,18 @@
  143.                                
  144.                                 SUHOSIN_G(execution_depth) = 0;
  145.                                 if (SUHOSIN_G(log_phpscript_is_safe)) {
  146. +#if PHP_VERSION_ID < 50400
  147.                                         PG(safe_mode) = 0;
  148. +#endif
  149.                                         PG(open_basedir) = NULL;
  150.                                 }
  151.                                
  152.                                 zend_execute(new_op_array TSRMLS_CC);
  153.                                
  154.                                 SUHOSIN_G(execution_depth) = orig_execution_depth;
  155. +#if PHP_VERSION_ID < 50400
  156.                                 PG(safe_mode) = orig_safe_mode;
  157. +#endif
  158.                                 PG(open_basedir) = orig_basedir;
  159.                                
  160.  #ifdef ZEND_ENGINE_2
  161. --- a/sha256.c
  162. +++ b/sha256.c
  163. @@ -86,9 +86,11 @@
  164.                 return;
  165.         }
  166.  
  167. +#if PHP_VERSION_ID < 50400
  168.         if (PG(safe_mode) && (!php_checkuid(arg, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
  169.                 RETURN_FALSE;
  170.         }
  171. +#endif
  172.  
  173.         if (php_check_open_basedir(arg TSRMLS_CC)) {
  174.                 RETURN_FALSE;
  175. @@ -392,7 +394,11 @@
  176.  
  177.  /* {{{ suhosin_sha256_functions[]
  178.   */
  179. +#if PHP_VERSION_ID < 50400
  180.  static function_entry suhosin_sha256_functions[] = {
  181. +#else
  182. +static zend_function_entry suhosin_sha256_functions[] = {
  183. +#endif
  184.         PHP_NAMED_FE(sha256, PHP_FN(suhosin_sha256), NULL)
  185.         PHP_NAMED_FE(sha256_file, PHP_FN(suhosin_sha256_file), NULL)
  186.         {NULL, NULL, NULL}
  187. --- a/suhosin.c
  188. +++ b/suhosin.c
  189. @@ -646,12 +646,16 @@
  190.                                 array_init(gpc_element);
  191.                                 zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
  192.                         } else {
  193. +#if PHP_VERSION_ID < 50400
  194.                                 if (PG(magic_quotes_gpc) && (index != var)) {
  195.                                         /* no need to addslashes() the index if it's the main variable name */
  196.                                         escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
  197.                                 } else {
  198. +#endif
  199.                                         escaped_index = index;
  200. +#if PHP_VERSION_ID < 50400
  201.                                 }
  202. +#endif
  203.                                 if (zend_symtable_find(symtable1, escaped_index, index_len + 1, (void **) &gpc_element_p) == FAILURE
  204.                                         || Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
  205.                                         MAKE_STD_ZVAL(gpc_element);
  206. @@ -683,11 +687,15 @@
  207.                 if (!index) {
  208.                         zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
  209.                 } else {
  210. +#if PHP_VERSION_ID < 50400
  211.                         if (PG(magic_quotes_gpc)) {
  212.                                 escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
  213.                         } else {
  214. +#endif
  215.                                 escaped_index = index;
  216. +#if PHP_VERSION_ID < 50400
  217.                         }
  218. +#endif
  219.                         /*
  220.                          * According to rfc2965, more specific paths are listed above the less specific ones.
  221.                          * If we encounter a duplicate cookie name, we should skip it, since it is not possible
  222. @@ -714,11 +722,15 @@
  223.        
  224.         /* Prepare value */
  225.         Z_STRLEN(new_entry) = str_len;
  226. +#if PHP_VERSION_ID < 50400
  227.         if (PG(magic_quotes_gpc)) {
  228.                 Z_STRVAL(new_entry) = php_addslashes(strval, Z_STRLEN(new_entry), &Z_STRLEN(new_entry), 0 TSRMLS_CC);
  229.         } else {
  230. +#endif
  231.                 Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry));
  232. +#if PHP_VERSION_ID < 50400
  233.         }
  234. +#endif
  235.         Z_TYPE(new_entry) = IS_STRING;
  236.  
  237.         suhosin_register_cookie_variable(var, &new_entry, track_vars_array TSRMLS_CC);
  238. --- a/ex_imp.c
  239. +++ b/ex_imp.c
  240. @@ -727,7 +727,11 @@
  241.  
  242.  /* {{{ suhosin_ex_imp_functions[]
  243.   */
  244. +#if PHP_VERSION_ID < 50400
  245.  function_entry suhosin_ex_imp_functions[] = {
  246. +#else
  247. +zend_function_entry suhosin_ex_imp_functions[] = {
  248. +#endif
  249.         PHP_NAMED_FE(extract, PHP_FN(suhosin_extract), suhosin_arginfo_extract)
  250.         PHP_NAMED_FE(import_request_variables, PHP_FN(suhosin_import_request_variables), suhosin_arginfo_import_request_variables)
  251.         {NULL, NULL, NULL}

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at