From 2923441cf824cbfac43ae51a65bcf3481ae5aefe Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Thu, 14 Nov 2013 18:43:37 -0800 Subject: [PATCH] bash: apply patch for bad strcpy in decode_prompt_string Closes Homebrew/homebrew#23470. --- Formula/bash.rb | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Formula/bash.rb b/Formula/bash.rb index 0ed6e68d2f..34cffee046 100644 --- a/Formula/bash.rb +++ b/Formula/bash.rb @@ -15,8 +15,13 @@ class Bash < Formula # and the more patches there are, the more unreliable they get. Upstream # patches can be found in: http://ftpmirror.gnu.org/bash/bash-4.2-patches def patches - { :p0 => "https://gist.github.com/jacknagel/4008180/raw/1509a257060aa94e5349250306cce9eb884c837d/bash-4.2-001-045.patch" } - end unless build.head? + # http://article.gmane.org/gmane.comp.shells.bash.bugs/20242 + p = { :p1 => DATA } + if build.stable? + p[:p0] = "https://gist.github.com/jacknagel/4008180/raw/1509a257060aa94e5349250306cce9eb884c837d/bash-4.2-001-045.patch" + end + p + end def install # When built with SSH_SOURCE_BASHRC, bash will source ~/.bashrc when @@ -37,3 +42,23 @@ class Bash < Formula EOS end end + +__END__ +diff --git a/parse.y b/parse.y +index b5c94e7..0cda47c 100644 +--- a/parse.y ++++ b/parse.y +@@ -5262,7 +5262,12 @@ decode_prompt_string (string) + else + /* polite_directory_format is guaranteed to return a string + no longer than PATH_MAX - 1 characters. */ +- strcpy (t_string, polite_directory_format (t_string)); ++ /* polite_directory_format might simply return the pointer to t_string ++ strcpy(3) tells dst and src may not overlap, OS X 10.9 asserts this and ++ triggers an abort trap if that's the case */ ++ temp = polite_directory_format (t_string); ++ if (temp != t_string) ++ strcpy (t_string, temp); + + temp = trim_pathname (t_string, PATH_MAX - 1); + /* If we're going to be expanding the prompt string later,