Fix missing null terminator when calling execv() on modprobe (#13054)

Blue committed Jun 5, 2025 at 01:11 UTC 0c8844e0f2f45e0e3f12c21d355d877a61adddf0
2 files changed +2 -2
src/linux/init/main.cpp
+1 -1
@@ -3383,7 +3383,7 @@ try
3383 const std::string KernelModulesList = wsl::shared::string::FromSpan(Buffer, EarlyConfig->KernelModulesListOffset);
3384 for (const auto& Module : wsl::shared::string::Split(KernelModulesList, ','))
3385 {
3386 - const char* Argv[] = {MODPROBE_PATH, Module.c_str()};
3386 + const char* Argv[] = {MODPROBE_PATH, Module.c_str(), nullptr};
3387 int Status = -1;
3388 auto result = UtilCreateProcessAndWait(MODPROBE_PATH, Argv, &Status);
3389 if (result < 0)
src/linux/init/util.cpp
+1 -1
@@ -682,7 +682,7 @@ Return Value:
682 // 2. In sometime we probably will replace most of these string constants
683 // with std::string anyway.
684 execv(File, const_cast<char* const*>(Argv));
685 - LOG_ERROR("{} failed with {}", File, errno);
685 + LOG_ERROR("execv({}) failed with {}", File, errno);
686 exit(-1);
687 }
688