Boost C++ Libraries: Ticket #13125: parse_config_file silently ignores IO errors https://svn.boost.org/trac10/ticket/13125 <p> The function <code>parse_config_file</code> silently ignores I/O errors while reading the configuration file. </p> <p> A easy way to reproduce the bug is to specify a directory as configuration file. On Linux, <code>open</code> will succeed but subsequent calls to <code>read</code> will fail with <code>EISDIR</code>. </p> <p> --- </p> <p> Minimal and complete program to reproduce the problem: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;cerrno&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/program_options.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">program_options</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="n">argc</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Invalid amount of arguments&quot;</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">1</span><span class="p">;</span> <span class="p">}</span> <span class="k">try</span> <span class="p">{</span> <span class="n">options_description</span> <span class="n">desc</span><span class="p">(</span><span class="s">&quot;Desc&quot;</span><span class="p">);</span> <span class="n">variables_map</span> <span class="n">vm</span><span class="p">;</span> <span class="n">store</span><span class="p">(</span><span class="n">parse_config_file</span><span class="o">&lt;</span><span class="kt">char</span><span class="o">&gt;</span><span class="p">(</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">desc</span><span class="p">),</span> <span class="n">vm</span><span class="p">);</span> <span class="n">notify</span><span class="p">(</span><span class="n">vm</span><span class="p">);</span> <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="n">error</span> <span class="o">&amp;</span><span class="n">e</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Error: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">e</span><span class="p">.</span><span class="n">what</span><span class="p">()</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">1</span><span class="p">;</span> <span class="p">}</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Everything fine&quot;</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><pre class="wiki">$ ./a.out some-non-existent-file Error: can not read options configuration file 'some-non-existent-file' $ ./a.out . Everything fine </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13125 Trac 1.4.3 Johannes Spangenberg <johannes.spangenberg@…> Sun, 16 Jul 2017 12:44:09 GMT <link>https://svn.boost.org/trac10/ticket/13125#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13125#comment:1</guid> <description> <p> Since I was not able to attach a patch to this issue <em>(Trac error: "<a class="missing wiki">IndexError</a>: pop from empty list")</em>, I created a pull request on <a class="missing wiki">GitHub</a>. </p> <p> <a class="ext-link" href="https://github.com/boostorg/program_options/pull/29"><span class="icon">​</span>https://github.com/boostorg/program_options/pull/29</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>