From 04128f97ee2444253b636ed52c4138d1e754b8f3 Mon Sep 17 00:00:00 2001 From: nielash Date: Tue, 9 Apr 2024 07:17:00 -0400 Subject: [PATCH] bisync: fix endless loop if lockfile decoder errors Before this change, the decoder looked only for `io.EOF`, and if any other error was returned, it could cause an infinite loop. This change fixes the issue by breaking for any non-nil error. --- cmd/bisync/lockfile.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/bisync/lockfile.go b/cmd/bisync/lockfile.go index 282fbdd1a..876b9cde6 100644 --- a/cmd/bisync/lockfile.go +++ b/cmd/bisync/lockfile.go @@ -99,7 +99,10 @@ func (b *bisyncRun) lockFileIsExpired() bool { b.handleErr(b.lockFile, "error reading lock file", err, true, true) dec := json.NewDecoder(rdf) for { - if err := dec.Decode(&data); err == io.EOF { + if err := dec.Decode(&data); err != nil { + if err != io.EOF { + fs.Errorf(b.lockFile, "err: %v", err) + } break } }