mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Fix input validation issues in llvm-as/llvm-dis
Summary: 1. llvm-as/llvm-dis tools do not check for input filename length. 2. llvm-dis does not verify the `Streamer` variable against `nullptr` properly, so the `M` variable could be uninitialized (e.g. if the input file does not exist) leading to null dref. Patch by Lenar Safin! Reviewers: samsonov Reviewed By: samsonov Subscribers: samsonov, llvm-commits Differential Revision: http://reviews.llvm.org/D9584 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237051 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -62,14 +62,8 @@ static void WriteOutputFile(const Module *M) {
|
||||
if (InputFilename == "-") {
|
||||
OutputFilename = "-";
|
||||
} else {
|
||||
std::string IFN = InputFilename;
|
||||
int Len = IFN.length();
|
||||
if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
|
||||
// Source ends in .ll
|
||||
OutputFilename = std::string(IFN.begin(), IFN.end()-3);
|
||||
} else {
|
||||
OutputFilename = IFN; // Append a .bc to it
|
||||
}
|
||||
StringRef IFN = InputFilename;
|
||||
OutputFilename = (IFN.endswith(".ll") ? IFN.drop_back(3) : IFN).str();
|
||||
OutputFilename += ".bc";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user