aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-04-05 16:04:09 -0700
committerIan Lance Taylor <iant@golang.org>2022-04-05 16:09:34 -0700
commit6be9d752142a03830e4202bd73f2765510ff9314 (patch)
treef9a48612019f56acdfdc7bd8b6397e2b102fc746 /libbacktrace
parent0b5723d74f3a731380f78dc1a02a2376951388cf (diff)
libbacktrace: don't skip initial aligned byte in uncompressed block
Patch from Rui Ueyama, who says: libbacktrace occasionally fails to decompress compressed debug info even though the sections contain valid zlib streams. The cause of the issue is an off-by-one error. If a zlib data block is a plain data (uncompressed data), the next two bytes contain the size of the block. These two bytes value is byte- aligned, so if we read-ahead more than 8 bits, we need to unread it. So, the correct condition to determine whether or not we need to unread a byte is bits >= 8 and not bits > 8. Due to this error, if the last read bits happened to end at a byte boundary, the next byte would be skipped. That caused the decompression failure. This bug was originally reported against the mold linker. rui314/mold#402 * elf.c (elf_zlib_inflate): Don't skip initial aligned byte in uncompressed block.
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/elf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 5c7c21a8da7..8b82dd45875 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -1796,7 +1796,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
/* An uncompressed block. */
/* If we've read ahead more than a byte, back up. */
- while (bits > 8)
+ while (bits >= 8)
{
--pin;
bits -= 8;