Subject: [Boost-bugs] [Boost C++ Libraries] #13125: parse_config_file silently ignores IO errors
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-07-16 12:21:46
#13125: parse_config_file silently ignores IO errors
-------------------------------------------------+-------------------------
Reporter: Johannes Spangenberg | Owner: Vladimir
<johannes.spangenberg@â¦> | Prus
Type: Bugs | Status: new
Milestone: To Be Determined | Component:
| program_options
Version: Boost Release Branch | Severity: Problem
Keywords: |
-------------------------------------------------+-------------------------
The function `parse_config_file` silently ignores I/O errors while reading
the configuration file.
A easy way to reproduce the bug is to specify a directory as configuration
file. On Linux, `open` will succeed but subsequent calls to `read` will
fail with `EISDIR`.
---
Minimal and complete program to reproduce the problem:
{{{#!c++
#include <cerrno>
#include <iostream>
#include <boost/program_options.hpp>
using namespace boost::program_options;
int main(int argc, char *argv[])
{
if (argc != 2) {
std::cerr << "Invalid amount of arguments" << std::endl;
return 1;
}
try {
options_description desc("Desc");
variables_map vm;
store(parse_config_file<char>(argv[1], desc), vm);
notify(vm);
} catch (error &e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
std::cerr << "Everything fine" << std::endl;
return 0;
}
}}}
{{{
$ ./a.out some-non-existent-file
Error: can not read options configuration file 'some-non-existent-file'
$ ./a.out .
Everything fine
}}}
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13125> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-07-16 12:25:13 UTC