patch/backport-Avoid-invalid-memory-access-in-context-format-diffs.patch
Xibo.Wang 3e3761cbac Bakport commits from upstream
1. Skip "ed" test when the ed utility is not installed
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=a5b442c
2. Abort when cleaning up fails
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=b7b028a
3. Don't crash when RLIMIT_NOFILE is set to RLIM_INFINITY
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=61d7788
4. Avoid invalid memory access in context format diffs
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=15b158d
5. Fix failed assertion 'outstate->after_newline'
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=76e7758
6. Add missing-section tests to context-format test case
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=78ed9de
7. Fix test for presence of BASH_LINENO[0]
	https://git.savannah.gnu.org/gitweb/?p=patch.git;a=commit;h=7623b2d
2022-12-30 16:04:49 +08:00

29 lines
783 B
Diff

From 46136e6440f78b4a21eaeaeabef2b4fcb482c158 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@gnu.org>
Date: Mon, 15 Jul 2019 19:10:02 +0200
Subject: [PATCH 4/8] Avoid invalid memory access in context format diffs
* src/pch.c (another_hunk): Avoid invalid memory access in context format
diffs.
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
---
src/pch.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/pch.c b/src/pch.c
index aa0caf4..87e6f93 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -1335,6 +1335,7 @@ another_hunk (enum diff difftype, bool rev)
ptrn_prefix_context = context;
ptrn_suffix_context = context;
if (repl_beginning
+ || p_end <= 0
|| (p_end
!= p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n')))
{
--
1.8.3.1