From 82721ef05336198c194f8519f294ab8c3b911597 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 3 Jul 2023 17:19:02 +0530 Subject: [PATCH] Check for error during seek() --- tools/rsync/algorithm.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/rsync/algorithm.go b/tools/rsync/algorithm.go index 916b3ad45..3406c1372 100644 --- a/tools/rsync/algorithm.go +++ b/tools/rsync/algorithm.go @@ -16,6 +16,7 @@ import ( "fmt" "hash" "io" + "os" ) // If no BlockSize is specified in the RSync instance, this value is used. @@ -178,7 +179,9 @@ func (r *RSync) ApplyDelta(alignedTarget io.Writer, target io.ReadSeeker, op Ope buffer := r.buffer writeBlock := func(op Operation) error { - target.Seek(int64(r.BlockSize*int(op.BlockIndex)), 0) + if _, err = target.Seek(int64(r.BlockSize*int(op.BlockIndex)), os.SEEK_SET); err != nil { + return err + } n, err = io.ReadAtLeast(target, buffer, r.BlockSize) if err != nil { if err != io.ErrUnexpectedEOF {