[PATCH] D82886: [DebugInfo] Fix a possible crash when reading a malformed .debug_*lists section.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 17:33:44 PDT 2020


dblaikie added a comment.

In D82886#2135527 <https://reviews.llvm.org/D82886#2135527>, @ikudrin wrote:

> In D82886#2134722 <https://reviews.llvm.org/D82886#2134722>, @dblaikie wrote:
>
> > Is that difference necessary? I tried removing the length == 0 special case from "length()" and no tests fail. Perhaps we could go that route instead?
>
>
> For example, `dumpRnglistsSection()` in `DWARFContext.cpp` terminates the loop when `length()` returns 0. With a specially constructed input, your variant would result in several additional unsuccessful reads with additional error messages:
>
>       .section .debug_rnglists,"", at progbits
>       .long 0xffffffff
>       .long 0xffffffff
>       .byte 0xff
>   ...
>   error: parsing .debug_rnglists table at offset 0x0: unexpected end of data at offset 0xb while reading [0x4, 0xc)
>   error: parsing .debug_rnglists table at offset 0x4: unexpected end of data at offset 0xb while reading [0x8, 0x10)
>   error: parsing .debug_rnglists table at offset 0x8: unexpected end of data at offset 0xb while reading [0x8, 0xc)
>


Ah, thanks! Would be handy to have a test case for that & perhaps some other way to communicate "end of list" that's a bit more explicit?

Hmm, I'm not sure why this produce the repetition - if length() accurately returned the length that was read rather than zero, then it'd go to the end and stop, right?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82886/new/

https://reviews.llvm.org/D82886





More information about the llvm-commits mailing list