From 9faf86a7256ca1cd6b6604dcdda99dfd2d5cdf9f Mon Sep 17 00:00:00 2001 From: lapla-cogito Date: Thu, 22 Aug 2024 23:14:20 +0900 Subject: [PATCH] remove temporary file after encryption --- src/error.rs | 3 +++ src/obfus.rs | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 80e4b6b..c2e9bb8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -21,6 +21,9 @@ pub enum Error { #[error("failed to process obfuscation: {0}")] Obfuscation(&'static str), + #[error("failed to remove file: {0}")] + RemoveFile(std::io::Error), + #[error("not found: {0}")] NotFound(String), } diff --git a/src/obfus.rs b/src/obfus.rs index 35842bb..9ca2e10 100644 --- a/src/obfus.rs +++ b/src/obfus.rs @@ -347,7 +347,7 @@ impl Obfuscator { .map_err(crate::error::Error::Io)?; let mut encrypted_function_name = Vec::new(); - let mut tmp_file = std::fs::File::open("/tmp/encrypted_function_name") + let mut tmp_file = std::fs::File::open("/tmp/cattleya_encrypted_function_name") .map_err(crate::error::Error::OpenFile)?; tmp_file .read_to_end(&mut encrypted_function_name) @@ -365,6 +365,9 @@ impl Obfuscator { .copy_from_slice(&encrypted_function_name); } + std::fs::remove_file("/tmp/cattleya_encrypted_function_name") + .map_err(crate::error::Error::RemoveFile)?; + Ok(()) } }