Skip to content

debug/elf: makeslice: len out of range #10997

Description

@dvyukov

The following program crashes with the panic on the provided input:

package main

import (
    "bytes"
    "debug/elf"
    "io/ioutil"
    "os"
)

func main() {
    data, _ := ioutil.ReadFile(os.Args[1])
    f, err := elf.NewFile(bytes.NewReader(data))
    if err != nil {
        if f != nil {
            panic("file is not nil on error")
        }
        return
    }
    defer f.Close()
    f.DynamicSymbols()
    f.ImportedLibraries()
    f.ImportedSymbols()
    f.Section(".data")
    f.SectionByType(elf.SHT_GNU_VERSYM)
    f.Symbols()
    dw, err := f.DWARF()
    if err != nil {
        if dw != nil {
            panic("dwarf is not nil on error")
        }
        return
    }
    dr := dw.Reader()
    for {
        e, _ := dr.Next()
        if e == nil {
            break
        }
    }
}
panic: runtime error: makeslice: len out of range

goroutine 1 [running]:
debug/elf.(*Section).Data(0xc208020ea0, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/debug/elf/file.go:78 +0x6e
debug/elf.NewFile(0x7ff342f88260, 0xc208014480, 0x645940, 0x0, 0x0)
    src/debug/elf/file.go:380 +0x111b
main.main()
    elftest.go:12 +0x11d

The input is:
https://drive.google.com/file/d/0B20Uwp8Hs1oCZUhqS3RiWFRja1U/view?usp=sharing

on commit 596bb76

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions