Fix potential crash when parsing broken Surge subscription

Optimize codes.
This commit is contained in:
Tindy X committed 2020-06-27 12:47:22 +08:00
1 parent c9e665801f
commit 90724c26cf
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -2430,7 +2430,7 @@ int simpleGenerator()
{
if(y.first == "Subscription-UserInfo")
{
std::cerr<<"User Info for artifact '"<<x<<"': "<<subInfoToMessage(y.second)<<"\n";
writeLog(0, "User Info for artifact '" + x + "': " + subInfoToMessage(y.second), LOG_LEVEL_INFO);
break;
}
}
+3 -1
View File
@@ -1333,7 +1333,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
*/
regGetMatch(x.second, proxystr, 3, NULL, &remarks, &config);
configs = split(config, ",");
if(configs.size() < 2)
if(configs.size() < 3)
continue;
switch(hash_(configs[0]))
{
@@ -1358,6 +1358,8 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
//if(mod_md5 == modSSMD5) //is SSEncrypt module
{
if(configs.size() < 5)
continue;
server = trim(configs[1]);
port = custom_port.empty() ? trim(configs[2]) : custom_port;
if(port == "0")