[lld] r263569 - ELF: Fix use-after-free problem.
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 14:04:37 PDT 2016
Thank you!
Filipe
On Tue, Mar 15, 2016 at 11:20 AM, Rui Ueyama via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: ruiu
> Date: Tue Mar 15 13:20:50 2016
> New Revision: 263569
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263569&view=rev
> Log:
> ELF: Fix use-after-free problem.
>
> Fixes pr26908. This patch is based on Filipe Cabecinhas'
> patch (http://reviews.llvm.org/D18167)
>
> http://reviews.llvm.org/D18169
>
> Modified:
> lld/trunk/ELF/Driver.cpp
> lld/trunk/ELF/Driver.h
> lld/trunk/ELF/DriverUtils.cpp
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=263569&r1=263568&r2=263569&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Tue Mar 15 13:20:50 2016
> @@ -170,7 +170,8 @@ static bool hasZOption(opt::InputArgList
> }
>
> void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
> - opt::InputArgList Args = parseArgs(&Alloc, ArgsArr.slice(1));
> + ELFOptTable Parser;
> + opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
> if (Args.hasArg(OPT_help)) {
> printHelp(ArgsArr[0]);
> return;
>
> Modified: lld/trunk/ELF/Driver.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=263569&r1=263568&r2=263569&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.h (original)
> +++ lld/trunk/ELF/Driver.h Tue Mar 15 13:20:50 2016
> @@ -39,8 +39,14 @@ private:
> };
>
> // Parses command line options.
> -llvm::opt::InputArgList parseArgs(llvm::BumpPtrAllocator *A,
> - ArrayRef<const char *> Args);
> +class ELFOptTable : public llvm::opt::OptTable {
> +public:
> + ELFOptTable();
> + llvm::opt::InputArgList parse(ArrayRef<const char *> Argv);
> +
> +private:
> + llvm::BumpPtrAllocator Alloc;
> +};
>
> // Create enum with OPT_xxx values for each option in Options.td
> enum {
>
> Modified: lld/trunk/ELF/DriverUtils.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=263569&r1=263568&r2=263569&view=diff
> ==============================================================================
> --- lld/trunk/ELF/DriverUtils.cpp (original)
> +++ lld/trunk/ELF/DriverUtils.cpp Tue Mar 15 13:20:50 2016
> @@ -46,26 +46,21 @@ static const opt::OptTable::Info infoTab
> #undef OPTION
> };
>
> -class ELFOptTable : public opt::OptTable {
> -public:
> - ELFOptTable() : OptTable(infoTable) {}
> -};
> +ELFOptTable::ELFOptTable() : OptTable(infoTable) {}
>
> // Parses a given list of options.
> -opt::InputArgList elf::parseArgs(llvm::BumpPtrAllocator *A,
> - ArrayRef<const char *> Argv) {
> +opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) {
> // Make InputArgList from string vectors.
> - ELFOptTable Table;
> unsigned MissingIndex;
> unsigned MissingCount;
>
> // Expand response files. '@<filename>' is replaced by the file's contents.
> SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
> - StringSaver Saver(*A);
> + StringSaver Saver(Alloc);
> llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine, Vec);
>
> // Parse options and then do error checking.
> - opt::InputArgList Args = Table.ParseArgs(Vec, MissingIndex, MissingCount);
> + opt::InputArgList Args = this->ParseArgs(Vec, MissingIndex, MissingCount);
> if (MissingCount)
> error(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
> "\", expected " + Twine(MissingCount) +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list