From 653670e6fa5896aed015588b8dd632cb72c4677a Mon Sep 17 00:00:00 2001 From: grumbulon Date: Sat, 4 Feb 2023 17:18:18 -0500 Subject: [PATCH] return error if file being saved to /tmp is empty --- internal/util/fs.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/util/fs.go b/internal/util/fs.go index 14e6403..6c04f8f 100644 --- a/internal/util/fs.go +++ b/internal/util/fs.go @@ -10,6 +10,10 @@ func MakeLocal(filename, username string, buf []byte) error { return fmt.Errorf("file %s already exists: %w", filename, err) } + if len(buf) == 0 { + return fmt.Errorf("will not save empty file: %s to FS", filename) + } + f, err := os.Create("/tmp/tmpfile-" + filename + "-" + username) //nolint: gosec // this is set to nolint because I am doing everything os.CreateTemp does but here since I don't like some of the limitations if err != nil {