From f740b2fb23f1309ddd4b6dfc2496d9acf19ce506 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 30 Jan 2021 00:15:20 +0100 Subject: [PATCH] mem: check upload length before storing upload --- internal/backend/mem/mem_backend.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/backend/mem/mem_backend.go b/internal/backend/mem/mem_backend.go index 950ae122d..719ca46a5 100644 --- a/internal/backend/mem/mem_backend.go +++ b/internal/backend/mem/mem_backend.go @@ -81,14 +81,14 @@ func (be *MemoryBackend) Save(ctx context.Context, h restic.Handle, rd restic.Re return err } - be.data[h] = buf - debug.Log("saved %v bytes at %v", len(buf), h) - // sanity check if int64(len(buf)) != rd.Length() { return errors.Errorf("wrote %d bytes instead of the expected %d bytes", len(buf), rd.Length()) } + be.data[h] = buf + debug.Log("saved %v bytes at %v", len(buf), h) + return ctx.Err() }