]> Cypherpunks repositories - gostls13.git/commit
cmd/link/internal/ld: don't panic on short buildid
authorRhys Hiltner <rhys@justin.tv>
Fri, 4 Mar 2016 06:37:14 +0000 (22:37 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 4 Mar 2016 21:20:09 +0000 (21:20 +0000)
commit3375974e0d64f2d8105cb5f6ca4a44790506f8ad
treeefbb57d554f0ac0a61e0801fb0f82e95990c4c46
parentb5481dd0a635780e8ff35cb274a9b3d85fc7f608
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>
src/cmd/link/internal/ld/elf.go
test/fixedbugs/issue14636.go [new file with mode: 0644]