From 2d9176ef1418dcc5f5badd4b6a1aad608630d033 Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 18 Jun 2024 09:04:05 +0200 Subject: [PATCH] Properly handle directory read errors --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index df386af..449b68c 100644 --- a/main.go +++ b/main.go @@ -142,7 +142,12 @@ func listFiles(conn net.Conn, rpath string) { if rpath == "/" { path = "/" } - list, _ := os.ReadDir(path) + list, err := os.ReadDir(path) + if err != nil { + e := fmt.Sprint(err) + sendMessage(Response{Successful: false, Message: e}, conn) + return + } newList := FileList{} for _, v := range list {