[all-commits] [llvm/llvm-project] 2ad0ef: [llvm-readelf] - Do not try to read past the end o...

Georgii Rymar via All-commits all-commits at lists.llvm.org
Thu Jun 4 02:17:29 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ad0ef6ef19dd1678e05b6d219ea0fdd4853bb64
      https://github.com/llvm/llvm-project/commit/2ad0ef6ef19dd1678e05b6d219ea0fdd4853bb64
  Author: Georgii Rymar <grimar at accesssoftek.com>
  Date:   2020-06-04 (Thu, 04 Jun 2020)

  Changed paths:
    M llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
    M llvm/tools/llvm-readobj/ELFDumper.cpp

  Log Message:
  -----------
  [llvm-readelf] - Do not try to read past the end of the file when dumping the the SHT_GNU_HASH.

We have unobvious issue in the condition that is used to check
that we do not read past the EOF.

The problem is that the result of "GnuHashTable->nbuckets * 4" expression is uint32.
Because of that it was still possible to overflow it and pass the check.

There was no such problem with the "GnuHashTable->maskwords * sizeof(typename ELFT::Off)"
condition, because of `sizeof` on the right (which gives 64-bits value on x64),
but I've added an explicit conversion to 64-bit value for `GnuHashTable->maskwords` too.

Differential revision: https://reviews.llvm.org/D81103




More information about the All-commits mailing list