Skip to content

Commit 9b6d4bd

Browse files
committed
chdman: Disallow quotation marks in output bin filename
1 parent 578558c commit 9b6d4bd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tools/chdman.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,7 @@ static void do_extract_cd(parameters_map &params)
25642564

25652565
// split path and extension
25662566
int chop = default_name.find_last_of('.');
2567-
if (chop != -1)
2567+
if (chop != std::string::npos)
25682568
default_name.erase(chop, default_name.size());
25692569

25702570
// GDIs will always output as split bin
@@ -2600,13 +2600,16 @@ static void do_extract_cd(parameters_map &params)
26002600
output_bin_file_str = output_bin_file_fnd->second;
26012601

26022602
chop = (*output_bin_file_str).find_last_of('.');
2603-
if (chop != -1)
2603+
if (chop != std::string::npos)
26042604
{
26052605
output_bin_file_ext = (*output_bin_file_str).substr(chop, (*output_bin_file_str).size() - chop);
26062606
(*output_bin_file_str).erase(chop, (*output_bin_file_str).size());
26072607
}
26082608
}
26092609

2610+
if ((*output_bin_file_str).find('"') != std::string::npos)
2611+
report_error(1, "Output bin filename (%s) must not contain quotation marks", *output_bin_file_str);
2612+
26102613
// print some info
26112614
util::stream_format(std::cout, "Input CHD: %s\n", *params.find(OPTION_INPUT)->second);
26122615
util::stream_format(std::cout, "Output TOC: %s\n", *output_file_str->second);

0 commit comments

Comments
 (0)