File hg-mpatch-fix03.patch of Package mercurial.11266

# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1524924552 14400
# Node ID faa924469635512b72868b1552a1866a0f91db20
# Parent  1acfc35d478cdae60cf62c6f07fa6b6ad3070ea7
mpatch: ensure fragment start isn't past the end of orig (SEC)

Caught by oss-fuzz fuzzer during development.

This defect is OVE-20180430-0004. A CVE has not been obtained as of
this writing.

---
 mercurial/mpatch.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/mercurial/mpatch.c
+++ b/mercurial/mpatch.c
@@ -265,8 +265,8 @@ static int apply(char *buf, const char *
 	char *p = buf;
 
 	while (f != l->tail) {
-		if (f->start < last || f->end > len || last < 0) {
-			if (!PyErr_Occurred())
+		if (f->start < last || f->start > len || f->end > len ||
+		    last < 0) {
 				PyErr_SetString(mpatch_Error,
 				                "invalid patch");
 			return 0;
openSUSE Build Service is sponsored by