bash: apply patch for bad strcpy in decode_prompt_string

Closes Homebrew/homebrew#23470.
This commit is contained in:
Adam Vandenberg 2013-11-14 18:43:37 -08:00
parent f96ce8db3a
commit 2923441cf8

View file

@ -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,