summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2022-10-22 19:13:28 +0000
committerMichael Forney <mforney@mforney.org>2022-10-22 19:13:28 +0000
commit9a69a14279be575bb2b7891a9d6f5da28ac2927c (patch)
treeb3309a5b808a7d4f95a4d4b17fd9632f7c16b205
parente7b26bd4dfdd4dcb04a5a339e1ed87206fc9e83e (diff)
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.
-rw-r--r--sys/src/cmd/patch.c2
1 files changed, 1 insertions, 1 deletions
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){