!41 [sync] PR-38: [Backport]less:[add]backport patches from upstream

From: @openeuler-sync-bot 
Reviewed-by: @jiayi0118 
Signed-off-by: @jiayi0118
This commit is contained in:
openeuler-ci-bot 2022-12-16 11:13:53 +00:00 committed by Gitee
commit 22356716b4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 67 additions and 2 deletions

View File

@ -0,0 +1,29 @@
From 74c598dd717de5e00db3d4995ee23d01f3510516 Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Sun, 15 Aug 2021 17:38:21 -0700
Subject: [PATCH] Fix crash when enter invaid pattern in & command.
---
search.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/search.c b/search.c
index f619fbe..4cc6832 100644
--- a/search.c
+++ b/search.c
@@ -1908,7 +1908,11 @@ set_filter_pattern(pattern, search_type)
/* Create a new filter and add it to the filter_infos list. */
filter = ecalloc(1, sizeof(struct pattern_info));
init_pattern(filter);
- set_pattern(filter, pattern, search_type, 1);
+ if (set_pattern(filter, pattern, search_type, 1) < 0)
+ {
+ free(filter);
+ return;
+ }
filter->next = filter_infos;
filter_infos = filter;
}
--
2.27.0

View File

@ -0,0 +1,26 @@
From 1974e5f8cd628e5fc1075883f3eba3e5390860d3 Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Sat, 9 Oct 2021 18:15:58 -0700
Subject: [PATCH] Fix memory leak when using corrupt lesshst file.
---
mark.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mark.c b/mark.c
index cbb316f..6506683 100644
--- a/mark.c
+++ b/mark.c
@@ -59,6 +59,9 @@ cmark(m, ifile, pos, ln)
m->m_ifile = ifile;
m->m_scrpos.pos = pos;
m->m_scrpos.ln = ln;
+ if (m->m_filename != NULL)
+ /* Normally should not happen but a corrupt lesshst file can do it. */
+ free(m->m_filename);
m->m_filename = NULL;
}
--
2.27.0

View File

@ -1,11 +1,13 @@
Name: less
Version: 590
Release: 2
Release: 3
Summary: Less is a pager that displays text files.
License: GPLv3+ or BSD
URL: http://www.greenwoodsoftware.com/less
Source0: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
Patch0: less-394-time.patch
Patch0: less-394-time.patch
Patch6000: backport-Fix-memory-leak-when-using-corrupt-lesshst-file.patch
Patch6001: backport-Fix-crash-when-enter-invaid-pattern-in-command.patch
BuildRequires: gcc make ncurses-devel autoconf automake libtool
@ -44,6 +46,14 @@ autoreconf -ivf
%{_mandir}/man1/*
%changelog
* Fri Dec 9 2022 Eibz-Chan <chenbingzhao@huawei.com> - 590-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:[add] backport patches from upstream
Fix-memory-leak-when-using-corrupt-lesshst-file.patch
Fix-crash-when-enter-invaid-pattern-in-command.patch
* Thu Oct 13 2022 fuanan <fuanan3@h-partners.com> - 590-2
- DESC:fix the changelog exception macro