cmd/link/internal/ld: don't panic on short buildid
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: Brad Fitzpatrick <bradfitz@golang.org>
Showing
test/fixedbugs/issue14636.go
0 → 100644
Please register or sign in to comment