• 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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    3375974e
issue14636.go 1.23 KB