From 9a69a14279be575bb2b7891a9d6f5da28ac2927c Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 22 Oct 2022 19:13:28 +0000 Subject: 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. --- sys/src/cmd/patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/src/cmd/patch.c') diff --git a/sys/src/cmd/patch.c b/sys/src/cmd/patch.c index 5d882150b..787446823 100644 --- a/sys/src/cmd/patch.c +++ b/sys/src/cmd/patch.c @@ -528,7 +528,7 @@ search(Fbuf *f, Hunk *h, char *fname) 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){ -- cgit v1.2.3