[PATCH] D25516: [Object/ELF] - Check index argument in getSymbol().

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 15:07:08 PDT 2016


On second thought, we should never use report_fatal_error in libObject to
report corrupted input, because it enforces a specific error handling
policy rather than defer it to an application. Could you return an error
instead?

On Thu, Oct 20, 2016 at 1:12 AM, George Rimar <grimar at accesssoftek.com>
wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL284702: [Object/ELF] - Check index argument in
> getSymbol(). (authored by grimar).
>
> Changed prior to commit:
>   https://reviews.llvm.org/D25516?vs=74383&id=75271#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D25516
>
> Files:
>   llvm/trunk/include/llvm/Object/ELF.h
>
>
> Index: llvm/trunk/include/llvm/Object/ELF.h
> ===================================================================
> --- llvm/trunk/include/llvm/Object/ELF.h
> +++ llvm/trunk/include/llvm/Object/ELF.h
> @@ -168,7 +168,10 @@
>    ErrorOr<const Elf_Shdr *> getSection(uint32_t Index) const;
>
>    const Elf_Sym *getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
> -    return &symbols(Sec)[Index];
> +    Elf_Sym_Range Symbols = symbols(Sec);
> +    if (Index >= Symbols.size())
> +      report_fatal_error("Invalid symbol index");
> +    return &Symbols[Index];
>    }
>
>    ErrorOr<StringRef> getSectionName(const Elf_Shdr *Section) const;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161027/cd6fe764/attachment-0001.html>


More information about the llvm-commits mailing list