]> Cypherpunks repositories - gostls13.git/commitdiff
internal/xcoff: better handling of malformed symbol tables
authorThan McIntosh <thanm@google.com>
Mon, 22 Aug 2022 11:59:49 +0000 (07:59 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 22 Aug 2022 15:41:53 +0000 (15:41 +0000)
Check for malformed data when reading the number of aux
symbols associated with a symbol table entry.

Fixes #54584.

Change-Id: Ic2a8d4d6a1d481d585a065b8182de86294c3d3d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/425049
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

src/internal/xcoff/file.go

index 1c5a266caffb21f3ab5512400afbcba3e6d82cf9..e859de932a96234b3874a08bdbef6f8cfbc811c4 100644 (file)
@@ -283,6 +283,9 @@ func NewFile(r io.ReaderAt) (*File, error) {
                                return nil, err
                        }
                        numaux = int(se.Nnumaux)
+                       if numaux < 0 {
+                               return nil, fmt.Errorf("malformed symbol table, invalid number of aux symbols")
+                       }
                        sym.SectionNumber = int(se.Nscnum)
                        sym.StorageClass = int(se.Nsclass)
                        sym.Value = uint64(se.Nvalue)
@@ -303,6 +306,9 @@ func NewFile(r io.ReaderAt) (*File, error) {
                                return nil, err
                        }
                        numaux = int(se.Nnumaux)
+                       if numaux < 0 {
+                               return nil, fmt.Errorf("malformed symbol table, invalid number of aux symbols")
+                       }
                        sym.SectionNumber = int(se.Nscnum)
                        sym.StorageClass = int(se.Nsclass)
                        sym.Value = se.Nvalue