]> Cypherpunks repositories - gostls13.git/commitdiff
debug/dwarf: handle malformed line table with bad program offset
authorThan McIntosh <thanm@google.com>
Thu, 23 Jun 2022 18:11:59 +0000 (14:11 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 23 Jun 2022 19:05:29 +0000 (19:05 +0000)
Touch up the line table reader to ensure that it can detect and reject
an invalid program offset field in the table header.

Fixes #53329.

Change-Id: Ia8d684e909af3aca3014b4a3d0dfd431e3f5a9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/413814
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/debug/dwarf/line.go

index bb281fbdd93b71b5d4c901111829a0770e8a6859..4df4a1751f341ed049f6f184f7a2643ff41a5191 100644 (file)
@@ -215,7 +215,11 @@ func (r *LineReader) readHeader(compDir string) error {
        } else {
                headerLength = Offset(buf.uint32())
        }
-       r.programOffset = buf.off + headerLength
+       programOffset := buf.off + headerLength
+       if programOffset > r.endOffset {
+               return DecodeError{"line", hdrOffset, fmt.Sprintf("malformed line table: program offset %d exceeds end offset %d", programOffset, r.endOffset)}
+       }
+       r.programOffset = programOffset
        r.minInstructionLength = int(buf.uint8())
        if r.version >= 4 {
                // [DWARF4 6.2.4]