From 5dd3ac523afd3784aba703baaec91fc1631916d9 Mon Sep 17 00:00:00 2001 From: kthui <18255193+kthui@users.noreply.github.com> Date: Tue, 7 Nov 2023 16:29:42 -0800 Subject: [PATCH] Add check for well formed runtime --- src/backend_model.cc | 1 + src/model_config_utils.cc | 15 +++++++++++++++ src/model_config_utils.h | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/src/backend_model.cc b/src/backend_model.cc index 03ee0e812..51ebc4117 100644 --- a/src/backend_model.cc +++ b/src/backend_model.cc @@ -318,6 +318,7 @@ TritonModel::GetBackendLibraryProperties( } python_backend_based_backend_libdir = *backend_libdir; } else { + RETURN_IF_ERROR(IsRuntimeLibraryNameWellFormed(backend_libname)); *is_python_backend_based_backend = backend_libname == kPythonFilename; } diff --git a/src/model_config_utils.cc b/src/model_config_utils.cc index 13f9c09bb..df62ad03d 100644 --- a/src/model_config_utils.cc +++ b/src/model_config_utils.cc @@ -2466,4 +2466,19 @@ AssembleCPPRuntimeLibraryName(const std::string& backend_name) #endif } +Status +IsRuntimeLibraryNameWellFormed(const std::string& library_name) +{ + const static std::vector excluded_strings = {"\\", "/"}; + for (const auto& excluded_str : excluded_strings) { + if (library_name.find(excluded_str) != library_name.npos) { + return Status( + Status::Code::INVALID_ARG, + "Model configuration runtime field contains illegal sub-string '" + + excluded_str + "'"); + } + } + return Status::Success; +} + }} // namespace triton::core diff --git a/src/model_config_utils.h b/src/model_config_utils.h index 0b6827c87..0767c6bd7 100644 --- a/src/model_config_utils.h +++ b/src/model_config_utils.h @@ -327,4 +327,10 @@ std::string InstanceConfigSignature( /// \return The assembled C++ runtime library name. std::string AssembleCPPRuntimeLibraryName(const std::string& backend_name); +/// Check if runtime library name is well formed. +/// \param library_name The library name to check. +/// \return Success status if '\' and '/' characters are not in library name. +/// Error status if otherwise. +Status IsRuntimeLibraryNameWellFormed(const std::string& library_name); + }} // namespace triton::core