mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: check magic header
Change-Id: I84b0e1d86728a76bc6a87fee4accf6fc43d87006 Reviewed-on: https://go-review.googlesource.com/54814 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
392834ff2b
commit
d02647242d
2 changed files with 14 additions and 1 deletions
|
|
@ -724,8 +724,17 @@ func genhash(ctxt *Link, lib *Library) {
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
var magbuf [len(ARMAG)]byte
|
||||
if _, err := io.ReadFull(f, magbuf[:]); err != nil {
|
||||
Exitf("file %s too short", lib.File)
|
||||
}
|
||||
|
||||
if string(magbuf[:]) != ARMAG {
|
||||
Exitf("%s is not an archive file", lib.File)
|
||||
}
|
||||
|
||||
var arhdr ArHdr
|
||||
l := nextar(f, int64(len(ARMAG)), &arhdr)
|
||||
l := nextar(f, f.Offset(), &arhdr)
|
||||
if l <= 0 {
|
||||
Errorf(nil, "%s: short read on archive file symbol header", lib.File)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue