From 31c9d4de1db2bed655bdb80620f34e92fd95a928 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 29 Dec 2022 11:42:54 +1100 Subject: [PATCH] Verify target triple retrieved from `rustc` is valid (#637) Signed-off-by: Jiahao XU --- crates/detect-targets/src/detect.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/detect-targets/src/detect.rs b/crates/detect-targets/src/detect.rs index 71940e71..b2b859d0 100644 --- a/crates/detect-targets/src/detect.rs +++ b/crates/detect-targets/src/detect.rs @@ -95,4 +95,6 @@ async fn get_target_from_rustc() -> Option { .lines() .filter_map(|line| line.ok()) .find_map(|line| line.strip_prefix("host: ").map(|host| host.to_owned())) + // All valid target triple must be in the form of $arch-$os-$abi. + .filter(|target| target.split('-').count() >= 3) }