Guest User

Untitled

a guest
Sep 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. #!/bin/bash
  2. # Patch apllying tool template
  3. # v0.1.2
  4. # (c) Copyright 2013. Magento Inc.
  5. #
  6. # DO NOT CHANGE ANY LINE IN THIS FILE.
  7.  
  8. # 1. Check required system tools
  9. _check_installed_tools() {
  10. local missed=""
  11.  
  12. until [ -z "$1" ]; do
  13. type -t $1 >/dev/null 2>/dev/null
  14. if (( $? != 0 )); then
  15. missed="$missed $1"
  16. fi
  17. shift
  18. done
  19.  
  20. echo $missed
  21. }
  22.  
  23. REQUIRED_UTILS='sed patch'
  24. MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
  25. if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
  26. then
  27. echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:nTool(s) "$MISSED_REQUIRED_TOOLS" is(are) missed, please install it(them)."
  28. exit 1
  29. fi
  30.  
  31. # 2. Determine bin path for system tools
  32. CAT_BIN=`which cat`
  33. PATCH_BIN=`which patch`
  34. SED_BIN=`which sed`
  35. PWD_BIN=`which pwd`
  36. BASENAME_BIN=`which basename`
  37.  
  38. BASE_NAME=`$BASENAME_BIN "$0"`
  39.  
  40. # 3. Help menu
  41. if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]
  42. then
  43. $CAT_BIN << EOFH
  44. Usage: sh $BASE_NAME [--help] [-R|--revert] [--list]
  45. Apply embedded patch.
  46.  
  47. -R, --revert Revert previously applied embedded patch
  48. --list Show list of applied patches
  49. --help Show this help message
  50. EOFH
  51. exit 0
  52. fi
  53.  
  54. # 4. Get "revert" flag and "list applied patches" flag
  55. REVERT_FLAG=
  56. SHOW_APPLIED_LIST=0
  57. if [ "$1" = "-R" -o "$1" = "--revert" ]
  58. then
  59. REVERT_FLAG=-R
  60. fi
  61. if [ "$1" = "--list" ]
  62. then
  63. SHOW_APPLIED_LIST=1
  64. fi
  65.  
  66. # 5. File pathes
  67. CURRENT_DIR=`$PWD_BIN`/
  68. APP_ETC_DIR=`echo "$CURRENT_DIR""app/etc/"`
  69. APPLIED_PATCHES_LIST_FILE=`echo "$APP_ETC_DIR""applied.patches.list"`
  70.  
  71. # 6. Show applied patches list if requested
  72. if [ "$SHOW_APPLIED_LIST" -eq 1 ] ; then
  73. echo -e "Applied/reverted patches list:"
  74. if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
  75. then
  76. if [ ! -r "$APPLIED_PATCHES_LIST_FILE" ]
  77. then
  78. echo "ERROR: "$APPLIED_PATCHES_LIST_FILE" must be readable so applied patches list can be shown."
  79. exit 1
  80. else
  81. $SED_BIN -n "/SUP-|SUPEE-/p" $APPLIED_PATCHES_LIST_FILE
  82. fi
  83. else
  84. echo "<empty>"
  85. fi
  86. exit 0
  87. fi
  88.  
  89. # 7. Check applied patches track file and its directory
  90. _check_files() {
  91. if [ ! -e "$APP_ETC_DIR" ]
  92. then
  93. echo "ERROR: "$APP_ETC_DIR" must exist for proper tool work."
  94. exit 1
  95. fi
  96.  
  97. if [ ! -w "$APP_ETC_DIR" ]
  98. then
  99. echo "ERROR: "$APP_ETC_DIR" must be writeable for proper tool work."
  100. exit 1
  101. fi
  102.  
  103. if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
  104. then
  105. if [ ! -w "$APPLIED_PATCHES_LIST_FILE" ]
  106. then
  107. echo "ERROR: "$APPLIED_PATCHES_LIST_FILE" must be writeable for proper tool work."
  108. exit 1
  109. fi
  110. fi
  111. }
  112.  
  113. _check_files
  114.  
  115. # 8. Apply/revert patch
  116. # Note: there is no need to check files permissions for files to be patched.
  117. # "patch" tool will not modify any file if there is not enough permissions for all files to be modified.
  118. # Get start points for additional information and patch data
  119. SKIP_LINES=$((`$SED_BIN -n "/^__PATCHFILE_FOLLOWS__$/=" "$CURRENT_DIR""$BASE_NAME"` + 1))
  120. ADDITIONAL_INFO_LINE=$(($SKIP_LINES - 3))p
  121.  
  122. _apply_revert_patch() {
  123. DRY_RUN_FLAG=
  124. if [ "$1" = "dry-run" ]
  125. then
  126. DRY_RUN_FLAG=" --dry-run"
  127. echo "Checking if patch can be applied/reverted successfully..."
  128. fi
  129. PATCH_APPLY_REVERT_RESULT=`$SED_BIN -e '1,/^__PATCHFILE_FOLLOWS__$/d' "$CURRENT_DIR""$BASE_NAME" | $PATCH_BIN $DRY_RUN_FLAG $REVERT_FLAG -p0`
  130. PATCH_APPLY_REVERT_STATUS=$?
  131. if [ $PATCH_APPLY_REVERT_STATUS -eq 1 ] ; then
  132. echo -e "ERROR: Patch can't be applied/reverted successfully.nn$PATCH_APPLY_REVERT_RESULT"
  133. exit 1
  134. fi
  135. if [ $PATCH_APPLY_REVERT_STATUS -eq 2 ] ; then
  136. echo -e "ERROR: Patch can't be applied/reverted successfully."
  137. exit 2
  138. fi
  139. }
  140.  
  141. REVERTED_PATCH_MARK=
  142. if [ -n "$REVERT_FLAG" ]
  143. then
  144. REVERTED_PATCH_MARK=" | REVERTED"
  145. fi
  146.  
  147. _apply_revert_patch dry-run
  148. _apply_revert_patch
  149.  
  150. # 9. Track patch applying result
  151. echo "Patch was applied/reverted successfully."
  152. ADDITIONAL_INFO=`$SED_BIN -n ""$ADDITIONAL_INFO_LINE"" "$CURRENT_DIR""$BASE_NAME"`
  153. APPLIED_REVERTED_ON_DATE=`date -u +"%F %T UTC"`
  154. APPLIED_REVERTED_PATCH_INFO=`echo -n "$APPLIED_REVERTED_ON_DATE"" | ""$ADDITIONAL_INFO""$REVERTED_PATCH_MARK"`
  155. echo -e "$APPLIED_REVERTED_PATCH_INFOn$PATCH_APPLY_REVERT_RESULTnn" >> "$APPLIED_PATCHES_LIST_FILE"
  156.  
  157. exit 0
  158.  
  159. SUPEE-9652 | EE_1.14.3.1 | v1 | 4038f0785d828794083f53f10c01aaa6af403523 | Tue Jan 24 15:03:12 2017 +0200 | 9586981e6ca8b255014b242d50b68b88525b0754..4038f0785d828794083f53f10c01aaa6af403523
  160.  
  161. __PATCHFILE_FOLLOWS__
  162. diff --git lib/Zend/Mail/Transport/Sendmail.php lib/Zend/Mail/Transport/Sendmail.php
  163. index b24026b..9323f58 100644
  164. --- lib/Zend/Mail/Transport/Sendmail.php
  165. +++ lib/Zend/Mail/Transport/Sendmail.php
  166. @@ -119,14 +119,19 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
  167. );
  168. }
  169.  
  170. - set_error_handler(array($this, '_handleMailErrors'));
  171. - $result = mail(
  172. - $this->recipients,
  173. - $this->_mail->getSubject(),
  174. - $this->body,
  175. - $this->header,
  176. - $this->parameters);
  177. - restore_error_handler();
  178. + // Sanitize the From header
  179. + if (!Zend_Validate::is(str_replace(' ', '', $this->parameters), 'EmailAddress')) {
  180. + throw new Zend_Mail_Transport_Exception('Potential code injection in From header');
  181. + } else {
  182. + set_error_handler(array($this, '_handleMailErrors'));
  183. + $result = mail(
  184. + $this->recipients,
  185. + $this->_mail->getSubject(),
  186. + $this->body,
  187. + $this->header,
  188. + $this->parameters);
  189. + restore_error_handler();
  190. + }
  191. }
  192.  
  193. if ($this->_errstr !== null || !$result) {
Add Comment
Please, Sign In to add comment