Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug/elf: slice bounds out of range #10999

Open
dvyukov opened this issue May 30, 2015 · 1 comment
Open

debug/elf: slice bounds out of range #10999

dvyukov opened this issue May 30, 2015 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented May 30, 2015

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

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
        }
    }
}

On input https://drive.google.com/file/d/0B20Uwp8Hs1oCQmk0YU1JaXM1N0E/view?usp=sharing

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
debug/elf.(*File).DynString(0xc208076000, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/debug/elf/file.go:1053 +0x6ad
debug/elf.(*File).ImportedLibraries(0xc208076000, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/debug/elf/file.go:1015 +0x4e
main.main()
    elftest.go:21 +0x1ec

On input https://drive.google.com/file/d/0B20Uwp8Hs1oCOXlsZGhXY2NhOW8/view?usp=sharing

panic: runtime error: index out of range

goroutine 1 [running]:
encoding/binary.(*littleEndian).Uint16(0x645be8, 0xc20800a954, 0x1, 0x1, 0xc208040003)
    <autogenerated>:8 +0xc9
debug/elf.(*File).gnuVersion(0xc208076000, 0x14, 0xc2080800f0)
    src/debug/elf/file.go:1002 +0xb8
debug/elf.(*File).ImportedSymbols(0xc208076000, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/debug/elf/file.go:914 +0x348
main.main()
    elftest.go:22 +0x1fa

on commit 596bb76

@dvyukov dvyukov added this to the Go1.5 milestone May 30, 2015
@rsc
Copy link
Contributor

rsc commented Jun 1, 2015

It's too late in the Go 1.5 release process for fuzzer bugs. The chance of hitting any of these is so low that the benefit of the fix is outweighed by the chance of the fix introducing a more serious bug.

@rsc rsc modified the milestones: Unplanned, Go1.5 Jun 1, 2015
@rsc rsc removed their assignment Jun 23, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants