mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-19 14:23:32 -04:00
add param string length check
Signed-off-by: sambaby <1337922982@qq.com>
This commit is contained in:
+3
-1
@@ -159,13 +159,15 @@ int main(int argc, char* argv[])
|
||||
CommandParser& parser = CommandParser::GetInstance();
|
||||
vector<string> 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;
|
||||
}
|
||||
|
||||
@@ -149,6 +149,8 @@ int main(int argc, char* argv[])
|
||||
CommandParser& parser = CommandParser::GetInstance();
|
||||
vector<string> strs;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (parser.IsMainArgLengthInvalid(argv[i]))
|
||||
return START_PARAM_INVALID_CODE;
|
||||
strs.push_back(argv[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user