• Rhys Hiltner's avatar
    cmd/link/internal/ld: don't panic on short buildid · 3375974e
    Rhys Hiltner authored
    When the linker was written in C, command line arguments were passed
    around as null-terminated byte arrays which encouraged checking
    characters one at a time. In Go, that can easily lead to
    out-of-bounds panics.
    
    Use the more idiomatic strings.HasPrefix when checking cmd/link's -B
    argument to avoid the panic, and replace the manual hex decode with
    use of the encoding/hex package.
    
    Fixes #14636
    
    Change-Id: I45f765bbd8cf796fee1a9a3496178bf76b117827
    Reviewed-on: https://go-review.googlesource.com/20211
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
    3375974e
elf.go 62.9 KB