shithub: riscv

Download patch

ref: 9a69a14279be575bb2b7891a9d6f5da28ac2927c
parent: e7b26bd4dfdd4dcb04a5a339e1ed87206fc9e83e
author: Michael Forney <mforney@mforney.org>
date: Sat Oct 22 15:13:28 EDT 2022

patch: fix bounds check for hunk scan in forward direction

Previously, hunks that end exactly at the end of the file could not be
found when the matching lines were located at a positive offset.

--- a/sys/src/cmd/patch.c
+++ b/sys/src/cmd/patch.c
@@ -528,7 +528,7 @@
 		ln = h->oldln + fuzz + 1;
 		if(ln > f->lastln && ln < f->nlines){
 			off = f->lines[ln];
-			if(off + len >= f->len)
+			if(off + len > f->len)
 				continue;
 			scanning = 1;
 			if(memcmp(f->buf + off, h->old, h->oldlen) == 0){