diff --git a/localization/strings/en-US/Resources.resw b/localization/strings/en-US/Resources.resw index 7e3f675aed..a114b29d02 100644 --- a/localization/strings/en-US/Resources.resw +++ b/localization/strings/en-US/Resources.resw @@ -3107,6 +3107,10 @@ On first run, creates the file with all settings commented out at their defaults Specify volume driver name, e.g. 'guest' or 'vhd' (default: guest) {Locked="guest"}{Locked="vhd"}Command line arguments, file names and string inserts should not be translated + + Invalid {} value: driver name cannot be empty or whitespace + {FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated + Set driver specific options diff --git a/src/windows/wslc/arguments/ArgumentValidation.cpp b/src/windows/wslc/arguments/ArgumentValidation.cpp index 7f507ea37a..af378cb59b 100644 --- a/src/windows/wslc/arguments/ArgumentValidation.cpp +++ b/src/windows/wslc/arguments/ArgumentValidation.cpp @@ -106,6 +106,17 @@ void Argument::Validate(const ArgMap& execArgs) const break; } + case ArgType::Driver: + { + const auto& value = execArgs.Get(); + if (value.empty() || + std::all_of(value.begin(), value.end(), [](wchar_t c) { return std::iswspace(static_cast(c)); })) + { + throw ArgumentException(Localization::WSLCCLI_DriverEmptyError(m_name)); + } + break; + } + case ArgType::Network: { for (const auto& value : execArgs.GetAll()) diff --git a/src/windows/wslc/services/ContainerService.cpp b/src/windows/wslc/services/ContainerService.cpp index 1015762ecc..7ea43b075e 100644 --- a/src/windows/wslc/services/ContainerService.cpp +++ b/src/windows/wslc/services/ContainerService.cpp @@ -72,7 +72,7 @@ static wsl::windows::common::RunningWSLCContainer CreateInternal( THROW_HR_WITH_USER_ERROR_IF( E_INVALIDARG, Localization::MessageWslcAliasRequiresUserDefinedNetwork(), - primary == "bridge" || primary == "host" || primary == "none" || primary.starts_with("container:")); + primary.empty() || primary == "bridge" || primary == "host" || primary == "none" || primary.starts_with("container:")); for (const auto& alias : options.NetworkAliases) {