From 834bfd08ab4a918989554ec025a63560d90e9b9a Mon Sep 17 00:00:00 2001
From: wenzhoufan <van203x@foxmail.com>
Date: Tue, 25 Mar 2025 11:22:53 +0800
Subject: [PATCH] fix: 修复部分程序无法用utf-8解码和asan程序未上传时报错的问题

---
 validation.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/validation.py b/validation.py
index bd22a5c..ca00308 100644
--- a/validation.py
+++ b/validation.py
@@ -50,7 +50,7 @@ def exec_command(crashes_collection, usage, command, seed_id: ObjectId):
     error_cause = ''
     process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     _, errs = process.communicate()
-    errs = str(errs, "utf-8")
+    errs = str(errs, "utf-8", errors='ignore')
     if usage == "valgrind":
         err_data = ''
         search_at_count = 0
@@ -152,16 +152,17 @@ def main(argv):
         fs = GridFS(default_db, fs_name)
         # 根据ObjectId查找文件
         print(software["asan_file"])
-        asan_file_data = fs.get(software["asan_file"])
-        if asan_file_data:
-            # 确保下载目录存在
-            os.makedirs(os.path.dirname(asan_file_path), exist_ok=True)
-            # 读取文件内容并保存到本地
-            with open(asan_file_path, "wb") as f:
-                f.write(asan_file_data.read())
-            os.system(f"chmod +x {asan_file_path}")
-            print("asan_file download successfully")
-            generation_command(crashes_collection, asan_file_path, parameter, crashes_file_paths, "")
+        if software["asan_file"] is not None:
+            asan_file_data = fs.get(software["asan_file"])
+            if asan_file_data:
+                # 确保下载目录存在
+                os.makedirs(os.path.dirname(asan_file_path), exist_ok=True)
+                # 读取文件内容并保存到本地
+                with open(asan_file_path, "wb") as f:
+                    f.write(asan_file_data.read())
+                os.system(f"chmod +x {asan_file_path}")
+                print("asan_file download successfully")
+                generation_command(crashes_collection, asan_file_path, parameter, crashes_file_paths, "")
     finally:
         task_collection.update_one({"_id": ObjectId(task_id)}, {"$set": {"verification": "VERIFIED"}})
         host_node = host_node_collection.find_one({"_id": ObjectId(host_node_id)})
--
libgit2 0.26.0