mirror of
https://github.com/fmang/opustags.git
synced 2025-01-15 12:43:17 +01:00
Open handles with O_CLOEXEC
opustags’s only use of a sub-process is for spawning the EDITOR, and we don’t want it to access our file handles.
This commit is contained in:
parent
57a4c0d5a0
commit
d54bada7e6
@ -319,7 +319,7 @@ static ot::status edit_tags_interactively(ot::opus_tags& tags, const std::option
|
||||
}
|
||||
|
||||
// Applying the new tags.
|
||||
tags_file = fopen(tags_path.c_str(), "r");
|
||||
tags_file = fopen(tags_path.c_str(), "re");
|
||||
if (tags_file == nullptr)
|
||||
return {ot::st::standard_error, "Error opening " + tags_path + ": " + strerror(errno)};
|
||||
if ((rc = ot::read_comments(tags_file, tags.comments)) != ot::st::ok) {
|
||||
@ -410,7 +410,7 @@ static ot::status run_single(const ot::options& opt, const std::string& path_in,
|
||||
ot::file input;
|
||||
if (path_in == "-")
|
||||
input = stdin;
|
||||
else if ((input = fopen(path_in.c_str(), "r")) == nullptr)
|
||||
else if ((input = fopen(path_in.c_str(), "re")) == nullptr)
|
||||
return {ot::st::standard_error,
|
||||
"Could not open '" + path_in + "' for reading: " + strerror(errno)};
|
||||
ot::ogg_reader reader(input.get());
|
||||
@ -450,7 +450,7 @@ static ot::status run_single(const ot::options& opt, const std::string& path_in,
|
||||
/* The output file exists. */
|
||||
if (!S_ISREG(output_info.st_mode)) {
|
||||
/* Special files are opened for writing directly. */
|
||||
if ((final_output = fopen(path_out->c_str(), "w")) == nullptr)
|
||||
if ((final_output = fopen(path_out->c_str(), "we")) == nullptr)
|
||||
rc = {ot::st::standard_error,
|
||||
"Could not open '" + path_out.value() + "' for writing: " +
|
||||
strerror(errno)};
|
||||
|
Loading…
x
Reference in New Issue
Block a user