diff --git a/RichPreviewer.cpp b/RichPreviewer.cpp index 5dedc85..5ffc1f8 100644 --- a/RichPreviewer.cpp +++ b/RichPreviewer.cpp @@ -159,13 +159,15 @@ int main(int argc, char* argv[]) CommandParser& parser = CommandParser::GetInstance(); vector strs; for (int i = 1; i < argc; ++i) { + if (parser.IsMainArgLengthInvalid(argv[i])) + return START_PARAM_INVALID_CODE; strs.push_back(argv[i]); } if (!parser.ProcessCommand(strs)) { return 0; } - + // check params if (!parser.IsCommandValid()) { return START_PARAM_INVALID_CODE; } diff --git a/ThinPreviewer.cpp b/ThinPreviewer.cpp index d2116d7..57b44f9 100644 --- a/ThinPreviewer.cpp +++ b/ThinPreviewer.cpp @@ -149,6 +149,8 @@ int main(int argc, char* argv[]) CommandParser& parser = CommandParser::GetInstance(); vector strs; for (int i = 1; i < argc; ++i) { + if (parser.IsMainArgLengthInvalid(argv[i])) + return START_PARAM_INVALID_CODE; strs.push_back(argv[i]); } diff --git a/util/CommandParser.cpp b/util/CommandParser.cpp index 9a662c0..1be3a70 100644 --- a/util/CommandParser.cpp +++ b/util/CommandParser.cpp @@ -848,4 +848,14 @@ bool CommandParser::IsStaticCardValid() staticCard = true; } return true; +} + +bool CommandParser::IsMainArgLengthInvalid(const char* str) const +{ + size_t argLength = strlen(str); + if (argLength > maxMainArgLength) { + ELOG("param size is more than %d", maxMainArgLength); + return true; + } + return false; } \ No newline at end of file diff --git a/util/CommandParser.h b/util/CommandParser.h index 015dbd6..a941eb6 100644 --- a/util/CommandParser.h +++ b/util/CommandParser.h @@ -58,6 +58,7 @@ public: bool IsComponentMode() const; std::string GetAbilityPath() const; bool IsStaticCard() const; + bool IsMainArgLengthInvalid(const char* str) const; private: CommandParser(); @@ -112,6 +113,7 @@ private: bool isComponentMode; std::string abilityPath; bool staticCard; + const size_t maxMainArgLength = 1024; bool IsDebugPortValid(); bool IsAppPathValid();