From f8c902b61c8667bbd5b8c962014c1133f615f7a7 Mon Sep 17 00:00:00 2001 From: Ahmed Elsayed Date: Tue, 7 Jan 2025 15:03:25 +0200 Subject: [PATCH] use shlex instead of split whitespaces. (#179) --- Cargo.toml | 1 + src/general_api.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0bc479f..58ca7ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ ipstack = { version = "0.1" } log = { version = "0.4", features = ["std"] } mimalloc = { version = "0.1", default-features = false, optional = true } percent-encoding = "2" +shlex = "1.3.0" socks5-impl = { version = "0.6", default-features = false, features = [ "tokio", ] } diff --git a/src/general_api.rs b/src/general_api.rs index d4bc0ce..665026e 100644 --- a/src/general_api.rs +++ b/src/general_api.rs @@ -88,7 +88,11 @@ pub unsafe extern "C" fn tun2proxy_run_with_cli_args(cli_args: *const c_char, tu let Ok(cli_args) = std::ffi::CStr::from_ptr(cli_args).to_str() else { return -5; }; - let args = ::parse_from(cli_args.split_whitespace()); + let Some(args) = shlex::split(cli_args) else { + log::error!("Failed to split CLI arguments"); + return -6; + }; + let args = ::parse_from(args); general_run_for_api(args, tun_mtu, packet_information) }