[libunwind] [libunwind] Avoid reading OOB for non-existent .eh_frame_hdr (PR #68815)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 11 09:46:23 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) {
----------------
arichardson wrote:

I don't feel strongly either way so I can change it if you prefer.

https://github.com/llvm/llvm-project/pull/68815


More information about the cfe-commits mailing list