Skip to content

Commit 2934cff

Browse files
committed
Redefined argument checking for internal raspberry pi camera
1 parent db2d5fe commit 2934cff

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

main/Helper.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,16 +871,31 @@ int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval
871871
return x->tv_sec < y->tv_sec;
872872
}
873873

874+
const char *szInsecureArgumentOptions[] = {
875+
"import",
876+
"socket",
877+
"process",
878+
"os",
879+
"|",
880+
";",
881+
"&",
882+
"$",
883+
"<",
884+
">",
885+
NULL
886+
};
887+
874888
bool IsArgumentSecure(const std::string &arg)
875889
{
876890
std::string larg(arg);
877891
std::transform(larg.begin(), larg.end(), larg.begin(), ::tolower);
878892

879-
return (
880-
(larg.find("-c") == std::string::npos)
881-
&& (larg.find("import") == std::string::npos)
882-
&& (larg.find("socket") == std::string::npos)
883-
&& (larg.find("process") == std::string::npos)
884-
&& (larg.find("os") == std::string::npos)
885-
);
893+
int ii = 0;
894+
while (szInsecureArgumentOptions[ii] != NULL)
895+
{
896+
if (larg.find(szInsecureArgumentOptions[ii]) != std::string::npos)
897+
return false;
898+
ii++;
899+
}
900+
return true;
886901
}

main/SQLHelper.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,20 +2809,17 @@ void CSQLHelper::Do_Work()
28092809
else if (itt->_ItemType == TITEM_EXECUTE_SCRIPT)
28102810
{
28112811
//start script
2812-
if (IsArgumentSecure(itt->_sValue))
2813-
{
2814-
_log.Log(LOG_STATUS, "Executing script: %s", itt->_ID.c_str());
2812+
_log.Log(LOG_STATUS, "Executing script: %s", itt->_ID.c_str());
28152813
#ifdef WIN32
2816-
ShellExecute(NULL, "open", itt->_ID.c_str(), itt->_sValue.c_str(), NULL, SW_SHOWNORMAL);
2814+
ShellExecute(NULL, "open", itt->_ID.c_str(), itt->_sValue.c_str(), NULL, SW_SHOWNORMAL);
28172815
#else
2818-
std::string lscript = itt->_ID + " " + itt->_sValue;
2819-
int ret = system(lscript.c_str());
2820-
if (ret != 0)
2821-
{
2822-
_log.Log(LOG_ERROR, "Error executing script command (%s). returned: %d", itt->_ID.c_str(), ret);
2823-
}
2824-
#endif
2816+
std::string lscript = itt->_ID + " " + itt->_sValue;
2817+
int ret = system(lscript.c_str());
2818+
if (ret != 0)
2819+
{
2820+
_log.Log(LOG_ERROR, "Error executing script command (%s). returned: %d", itt->_ID.c_str(), ret);
28252821
}
2822+
#endif
28262823
}
28272824
else if (itt->_ItemType == TITEM_EMAIL_CAMERA_SNAPSHOT)
28282825
{

main/WebServer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,8 +2989,6 @@ namespace http {
29892989
std::string strparm = szUserDataFolder;
29902990
if (!script_params.empty())
29912991
{
2992-
if (!IsArgumentSecure(script_params))
2993-
return;
29942992
if (strparm.size() > 0)
29952993
strparm += " " + script_params;
29962994
else

0 commit comments

Comments
 (0)