Merge pull request #4190 from ArchitDewan/fix/relinker-empty-path
fix(relinker): reject empty positional paths
This commit is contained in:
commit
71c3dbb722
|
|
@ -71,6 +71,8 @@ Args ParseArgs(int argc, char* argv[]) {
|
|||
args.windowsGui = true;
|
||||
} else if (arg.rfind("--", 0) == 0 || arg == "unused-filter") {
|
||||
throw std::runtime_error("unknown option: " + arg);
|
||||
} else if (arg.empty()) {
|
||||
throw std::runtime_error("input and output paths must be nonempty");
|
||||
} else if (args.inputPath.empty()) {
|
||||
args.inputPath = arg;
|
||||
} else if (args.outputPath.empty()) {
|
||||
|
|
|
|||
|
|
@ -163,6 +163,13 @@ void unknownOption() {
|
|||
expectThrows({"--", "input.elf", "output.elf"}, "unknown option: --");
|
||||
}
|
||||
|
||||
void emptyPositionals() {
|
||||
for (const auto& arguments : std::vector<std::vector<std::string>>{
|
||||
{"", "input.elf", "output.elf"}, {"input.elf", "", "output.elf"},
|
||||
{"", "output.elf"}, {"input.elf", ""}})
|
||||
expectThrows(arguments, "input and output paths must be nonempty");
|
||||
}
|
||||
|
||||
void tooManyPositionals() {
|
||||
expectThrows({"input.elf", "output.elf", "extra.elf"}, "unexpected argument: extra.elf");
|
||||
}
|
||||
|
|
@ -211,6 +218,7 @@ int main() {
|
|||
unusedFilterRejectsDuplicates();
|
||||
unusedFilterBareWordIsUnknown();
|
||||
unknownOption();
|
||||
emptyPositionals();
|
||||
tooManyPositionals();
|
||||
windowsDiagnosticsRequiresWindows();
|
||||
windowsGuiRequiresWindows();
|
||||
|
|
|
|||
Loading…
Reference in New Issue