Don't crash when use `read' with associative array

Patch from upstream. Fixes bug #715050.

Signed-off-by: Roman Rakus <rrakus@redhat.com>
This commit is contained in:
Roman Rakus 2011-06-22 15:42:05 +02:00
parent 02b20d8101
commit 35b6783bcd
2 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,40 @@
*** ../bash-4.2-patched/builtins/read.def 2011-01-04 11:43:36.000000000 -0500
--- builtins/read.def 2011-06-21 10:31:02.000000000 -0400
***************
*** 456,460 ****
add_unwind_protect (xfree, input_string);
interrupt_immediately++;
- terminate_immediately++;
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
--- 456,459 ----
***************
*** 513,516 ****
--- 512,516 ----
if (retval <= 0)
{
+ CHECK_TERMSIG;
eof = 1;
break;
***************
*** 623,627 ****
interrupt_immediately--;
- terminate_immediately--;
#if defined (ARRAY_VARS)
--- 623,626 ----
***************
*** 643,646 ****
--- 642,651 ----
return EXECUTION_FAILURE; /* readonly or noassign */
}
+ if (assoc_p (var))
+ {
+ builtin_error (_("%s: cannot convert associative to indexed array"), arrayname);
+ xfree (input_string);
+ return EXECUTION_FAILURE; /* existing associative array */
+ }
array_flush (array_cell (var));

View File

@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag}
Name: bash
Summary: The GNU Bourne Again shell
Release: 3%{?dist}
Release: 4%{?dist}
Group: System Environment/Shells
License: GPLv3+
Url: http://www.gnu.org/software/bash
@ -65,7 +65,9 @@ Patch120: bash-4.2-rc2-logout.patch
# Static analyzis shows some issues in bash-2.05a-interpreter.patch
Patch121: bash-4.2-coverity.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# 715050, Don't crash when use `read' with associative array
# Patch from upstream
Patch122: bash-4.1-read-assoc-array.patch
BuildRequires: texinfo bison
BuildRequires: ncurses-devel
@ -125,6 +127,8 @@ This package contains documentation files for %{name}.
%patch119 -p1 -b .broken_pipe
%patch120 -p1 -b .logout
%patch121 -p1 -b .coverity
# upstream patch
%patch122 -p0 -b .read-assoc-array
echo %{version} > _distribution
echo %{release} > _patchlevel
@ -312,6 +316,9 @@ end
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog
* Wed Jun 22 2011 Roman Rakus <rrakus@redhat.com> - 4.2.10-4
- Don't crash when use `read' with associative array (#715050)
* Tue Jun 07 2011 Roman Rakus <rrakus@redhat.com> - 4.2.10-3
- Added $HOME/.local/bin to PATH in .bash_profile (#699812)