From bfe3f6ae65159ca4f3ecaccbc71367b90ecdbf85 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 1 Aug 2023 12:09:54 +0900 Subject: [PATCH] [feat] check auth size --- src-tauri/src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c7e5ae21..31016a42 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -84,6 +84,16 @@ fn check_auth(fpath: String, auth: String) -> bool{ println!("File {} does not exist", path.display()); return false; } + // check file size + let size = std::fs::metadata(&fpath).unwrap().len(); + + //check file size is less than 1000 bytes + if size > 1000 { + println!("File {} is too large", path.display()); + return false; + } + + // read file let got_auth = std::fs::read_to_string(&path).expect("Something went wrong reading the file");