php5.5.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. diff --git a/lib/PageRender.php b/lib/PageRender.php
  2. index 7d86a54..eed5d5f 100644
  3. --- a/lib/PageRender.php
  4. +++ b/lib/PageRender.php
  5. @@ -287,7 +287,7 @@ class PageRender extends Visitor {
  6. break;
  7. default:
  8. - $vals[$i] = password_hash($passwordvalue,$enc);
  9. + $vals[$i] = password_hash_custom($passwordvalue,$enc);
  10. }
  11. $vals = array_unique($vals);
  12. @@ -957,7 +957,7 @@ class PageRender extends Visitor {
  13. if (trim($val))
  14. $enc_type = get_enc_type($val);
  15. else
  16. - $enc_type = $server->getValue('appearance','password_hash');
  17. + $enc_type = $server->getValue('appearance','password_hash_custom');
  18. $obfuscate_password = obfuscate_password_display($enc_type);
  19. @@ -982,7 +982,7 @@ class PageRender extends Visitor {
  20. if (trim($val))
  21. $enc_type = get_enc_type($val);
  22. else
  23. - $enc_type = $server->getValue('appearance','password_hash');
  24. + $enc_type = $server->getValue('appearance','password_hash_custom');
  25. echo '<table cellspacing="0" cellpadding="0"><tr><td valign="top">';
  26. diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php
  27. index c346660..7532539 100644
  28. --- a/lib/ds_ldap.php
  29. +++ b/lib/ds_ldap.php
  30. @@ -1116,13 +1116,24 @@ class ldap extends DS {
  31. if (is_array($dn)) {
  32. $a = array();
  33. - foreach ($dn as $key => $rdn)
  34. - $a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);
  35. + foreach ($dn as $key => $rdn) {
  36. + $a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',
  37. + function ($m) {
  38. + return ''.chr(hexdec('\\1')).'';
  39. + },
  40. + $rdn
  41. + );
  42. + }
  43. return $a;
  44. } else
  45. - return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);
  46. + return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',
  47. + function ($m) {
  48. + return ''.chr(hexdec('\\1')).'';
  49. + },
  50. + $dn
  51. + );
  52. }
  53. public function getRootDSE($method=null) {
  54. diff --git a/lib/ds_ldap_pla.php b/lib/ds_ldap_pla.php
  55. index 7ece393..6b0990e 100644
  56. --- a/lib/ds_ldap_pla.php
  57. +++ b/lib/ds_ldap_pla.php
  58. @@ -16,7 +16,7 @@ class ldap_pla extends ldap {
  59. function __construct($index) {
  60. parent::__construct($index);
  61. - $this->default->appearance['password_hash'] = array(
  62. + $this->default->appearance['password_hash_custom'] = array(
  63. 'desc'=>'Default HASH to use for passwords',
  64. 'default'=>'md5');
  65. diff --git a/lib/functions.php b/lib/functions.php
  66. index 56d8bf3..5ac3caf 100644
  67. --- a/lib/functions.php
  68. +++ b/lib/functions.php
  69. @@ -2127,7 +2127,7 @@ function password_types() {
  70. * crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, sha512, or clear.
  71. * @return string The hashed password.
  72. */
  73. -function password_hash($password_clear,$enc_type) {
  74. +function password_hash_custom($password_clear,$enc_type) {
  75. if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
  76. debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
  77. @@ -2318,7 +2318,7 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
  78. # SHA crypted passwords
  79. case 'sha':
  80. - if (strcasecmp(password_hash($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0)
  81. + if (strcasecmp(password_hash_custom($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0)
  82. return true;
  83. else
  84. return false;
  85. @@ -2327,7 +2327,7 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
  86. # MD5 crypted passwords
  87. case 'md5':
  88. - if( strcasecmp(password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)
  89. + if( strcasecmp(password_hash_custom($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)
  90. return true;
  91. else
  92. return false;
  93. @@ -2392,7 +2392,7 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
  94. # SHA512 crypted passwords
  95. case 'sha512':
  96. - if (strcasecmp(password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
  97. + if (strcasecmp(password_hash_custom($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
  98. return true;
  99. else
  100. return false;
  101. @@ -2564,13 +2564,24 @@ function dn_unescape($dn) {
  102. if (is_array($dn)) {
  103. $a = array();
  104. - foreach ($dn as $key => $rdn)
  105. - $a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);
  106. + foreach ($dn as $key => $rdn) {
  107. + $a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',
  108. + function ($m) {
  109. + return ''.chr(hexdec('\\1')).'';
  110. + },
  111. + $rdn
  112. + );
  113. + }
  114. return $a;
  115. } else {
  116. - return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);
  117. + return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',
  118. + function ($m) {
  119. + return ''.chr(hexdec('\\1')).'';
  120. + },
  121. + $dn
  122. + );
  123. }
  124. }