Resolves: #1722703 - make failed searches of history in Zle robust

This commit is contained in:
Kamil Dudka 2019-07-26 17:02:14 +02:00
parent 711462cd2d
commit 143732d608
2 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,92 @@
From 15c190164c375cfe1772ebec92b544ca26a60e28 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Tue, 23 Jul 2019 14:45:48 +0200
Subject: [PATCH 1/2] 44566: make sure Zle doesn't crash if history entry not
found
Upstream-commit: f9cd2187875b6f2ebdb9b9a787fac20b2aaf745b
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/Zle/zle_utils.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index c6df3d8..633f593 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1607,7 +1607,12 @@ static int
unapplychange(struct change *ch)
{
if(ch->hist != histline) {
- zle_setline(quietgethist(ch->hist));
+ Histent he = quietgethist(ch->hist);
+ if(!he) {
+ dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+ return 1;
+ }
+ zle_setline(he);
zlecs = ch->new_cs;
return 0;
}
@@ -1647,7 +1652,12 @@ static int
applychange(struct change *ch)
{
if(ch->hist != histline) {
- zle_setline(quietgethist(ch->hist));
+ Histent he = quietgethist(ch->hist);
+ if(!he) {
+ dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+ return 1;
+ }
+ zle_setline(he);
zlecs = ch->old_cs;
return 0;
}
--
2.20.1
From 10dedc96ce0de43372add239f8256e259ca1e04a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Fri, 26 Jul 2019 17:24:59 +0200
Subject: [PATCH 2/2] 44582: Fix foregoing commit to use DPUTS() better
Upstream-commit: d6a9e222ec6b006c09d6f84beae6ef488a19b214
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/Zle/zle_utils.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 633f593..29dba08 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1608,10 +1608,9 @@ unapplychange(struct change *ch)
{
if(ch->hist != histline) {
Histent he = quietgethist(ch->hist);
- if(!he) {
- dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+ DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL");
+ if(he == NULL)
return 1;
- }
zle_setline(he);
zlecs = ch->new_cs;
return 0;
@@ -1653,10 +1652,9 @@ applychange(struct change *ch)
{
if(ch->hist != histline) {
Histent he = quietgethist(ch->hist);
- if(!he) {
- dputs(ERRMSG("quietgethist(ch->hist) returned NULL"));
+ DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL");
+ if(he == NULL)
return 1;
- }
zle_setline(he);
zlecs = ch->old_cs;
return 0;
--
2.20.1

View File

@ -1,7 +1,7 @@
Summary: Powerful interactive shell Summary: Powerful interactive shell
Name: zsh Name: zsh
Version: 5.7.1 Version: 5.7.1
Release: 3%{?dist} Release: 4%{?dist}
License: MIT License: MIT
URL: http://zsh.sourceforge.net/ URL: http://zsh.sourceforge.net/
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
@ -12,6 +12,9 @@ Source4: zshrc.rhs
Source5: zshenv.rhs Source5: zshenv.rhs
Source6: dotzshrc Source6: dotzshrc
# make failed searches of history in Zle robust (#1722703)
Patch1: 0001-zsh-5.7.1-zle-history-avoid-crash.patch
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: gawk BuildRequires: gawk
@ -154,6 +157,9 @@ fi
%doc Doc/*.html %doc Doc/*.html
%changelog %changelog
* Fri Jul 26 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-4
- make failed searches of history in Zle robust (#1722703)
* Tue Mar 12 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-3 * Tue Mar 12 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-3
- avoid build failure in case we have working ypcat (#1687574) - avoid build failure in case we have working ypcat (#1687574)