mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
fixed infinite loops (#4200)
- fixed infinite loops in config utils operation with broken streams - added tests Co-authored-by: Andrey Masloboev <amasloboev@topcon.com>
This commit is contained in:
parent
701c8dae2d
commit
feee1650e4
@ -65,6 +65,10 @@ void IniFileConfiguration::load(std::istream& istr)
|
||||
_sectionKey.clear();
|
||||
while (!istr.eof())
|
||||
{
|
||||
if(istr.fail())
|
||||
{
|
||||
throw Poco::IOException("Broken input stream");
|
||||
}
|
||||
parseLine(istr);
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,10 @@ void PropertyFileConfiguration::load(std::istream& istr)
|
||||
clear();
|
||||
while (!istr.eof())
|
||||
{
|
||||
if(istr.fail())
|
||||
{
|
||||
throw Poco::IOException("Broken input stream");
|
||||
}
|
||||
parseLine(istr);
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,18 @@ void IniFileConfigurationTest::testLoad()
|
||||
assertTrue (std::find(keys.begin(), keys.end(), "section1") != keys.end());
|
||||
assertTrue (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
|
||||
assertTrue (std::find(keys.begin(), keys.end(), "Prop1") == keys.end());
|
||||
|
||||
std::istringstream istr_err(iniFile);
|
||||
istr_err.putback(std::ios_base::failbit);
|
||||
try
|
||||
{
|
||||
AutoPtr<IniFileConfiguration> pConf_err = new IniFileConfiguration(istr_err);
|
||||
}
|
||||
catch (Poco::IOException& exc)
|
||||
{
|
||||
std::string s(exc.message());
|
||||
assertTrue (s == "Broken input stream");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +85,18 @@ void PropertyFileConfigurationTest::testLoad()
|
||||
catch (NotFoundException&)
|
||||
{
|
||||
}
|
||||
|
||||
std::istringstream istr_err(propFile);
|
||||
istr_err.putback(std::ios_base::failbit);
|
||||
try
|
||||
{
|
||||
AutoPtr<PropertyFileConfiguration> pConf_err = new PropertyFileConfiguration(istr_err);
|
||||
}
|
||||
catch (Poco::IOException& exc)
|
||||
{
|
||||
std::string s(exc.message());
|
||||
assertTrue (s == "Broken input stream");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user