]> granicus.if.org Git - icinga2/commitdiff
Properly deal with I/O errors when parsing config files.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 23 Jan 2013 08:57:06 +0000 (09:57 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 23 Jan 2013 08:57:06 +0000 (09:57 +0100)
Fixes #3152

lib/config/configcompiler.cpp

index dfd06e98734a35a4471326a9e3dadb738bcef84f..29102788c530c2e5ab2d485da24aa83dc6fc7ed3 100644 (file)
@@ -55,7 +55,7 @@ ConfigCompiler::~ConfigCompiler(void)
  */
 size_t ConfigCompiler::ReadInput(char *buffer, size_t max_size)
 {
-       m_Input->read(buffer, max_size);
+       m_Input->readsome(buffer, max_size);
        return static_cast<size_t>(m_Input->gcount());
 }
 
@@ -122,6 +122,8 @@ void ConfigCompiler::HandleLibrary(const String& library)
 vector<ConfigItem::Ptr> ConfigCompiler::CompileStream(const String& path,
     istream *stream)
 {
+       stream->exceptions(istream::failbit | istream::badbit);
+
        ConfigCompiler ctx(path, stream);
        ctx.Compile();
        return ctx.GetResult();