[libunwind] [libunwind] Avoid reading OOB for non-existent .eh_frame_hdr (PR #68815)
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 11 09:12:01 PDT 2023
================
@@ -53,8 +53,21 @@ template <typename A> class EHHeaderParser {
template <typename A>
bool EHHeaderParser<A>::decodeEHHdr(A &addressSpace, pint_t ehHdrStart,
- pint_t ehHdrEnd, EHHeaderInfo &ehHdrInfo) {
+ size_t ehHdrSize, EHHeaderInfo &ehHdrInfo) {
pint_t p = ehHdrStart;
+ pint_t ehHdrEnd = ehHdrStart + ehHdrSize;
+
+ // Ensure that we don't read data beyond the end of .eh_frame_hdr
+ if (ehHdrSize < 4) {
----------------
compnerd wrote:
I wonder if we can keep the `eHdrEnd` and then just use the computation here of:
```c++
if (eHdrEnd - eHdrStart < 4) {
```
I think that giving the region is kinda nice and we need that value anyway.
https://github.com/llvm/llvm-project/pull/68815
More information about the cfe-commits
mailing list