mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-27 18:30:51 +02: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();
|
_sectionKey.clear();
|
||||||
while (!istr.eof())
|
while (!istr.eof())
|
||||||
{
|
{
|
||||||
|
if(istr.fail())
|
||||||
|
{
|
||||||
|
throw Poco::IOException("Broken input stream");
|
||||||
|
}
|
||||||
parseLine(istr);
|
parseLine(istr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,10 @@ void PropertyFileConfiguration::load(std::istream& istr)
|
|||||||
clear();
|
clear();
|
||||||
while (!istr.eof())
|
while (!istr.eof())
|
||||||
{
|
{
|
||||||
|
if(istr.fail())
|
||||||
|
{
|
||||||
|
throw Poco::IOException("Broken input stream");
|
||||||
|
}
|
||||||
parseLine(istr);
|
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(), "section1") != keys.end());
|
||||||
assertTrue (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
|
assertTrue (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
|
||||||
assertTrue (std::find(keys.begin(), keys.end(), "Prop1") == 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&)
|
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…
x
Reference in New Issue
Block a user