Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2350)

Delta Between Two Patch Sets: src/pkg/debug/elf/file.go

Issue 6936058: code review 6936058: debug/elf: handle missing shstrndx in core files (Closed)
Left Patch Set: diff -r 9e8d16052155 https://code.google.com/p/go Created 11 years, 3 months ago
Right Patch Set: diff -r 9a0e4777ea8b https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/debug/elf/file_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package elf implements access to ELF object files. 5 // Package elf implements access to ELF object files.
6 package elf 6 package elf
7 7
8 import ( 8 import (
9 "bytes" 9 "bytes"
10 "debug/dwarf" 10 "debug/dwarf"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return nil, &FormatError{0, "mismatched ELF version", v} 265 return nil, &FormatError{0, "mismatched ELF version", v}
266 } 266 }
267 phoff = int64(hdr.Phoff) 267 phoff = int64(hdr.Phoff)
268 phentsize = int(hdr.Phentsize) 268 phentsize = int(hdr.Phentsize)
269 phnum = int(hdr.Phnum) 269 phnum = int(hdr.Phnum)
270 shoff = int64(hdr.Shoff) 270 shoff = int64(hdr.Shoff)
271 shentsize = int(hdr.Shentsize) 271 shentsize = int(hdr.Shentsize)
272 shnum = int(hdr.Shnum) 272 shnum = int(hdr.Shnum)
273 shstrndx = int(hdr.Shstrndx) 273 shstrndx = int(hdr.Shstrndx)
274 } 274 }
275 » if shstrndx < 0 || shstrndx > shnum { 275
276 » if shnum > 0 && shoff > 0 && (shstrndx < 0 || shstrndx >= shnum) {
dvyukov 2015/05/29 18:41:47 shouldn't this be: if shnum < 0 || shoff < 0 ||
276 return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx} 277 return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
277 } 278 }
278 279
279 // Read program headers 280 // Read program headers
280 f.Progs = make([]*Prog, phnum) 281 f.Progs = make([]*Prog, phnum)
281 for i := 0; i < phnum; i++ { 282 for i := 0; i < phnum; i++ {
282 off := phoff + int64(i)*int64(phentsize) 283 off := phoff + int64(i)*int64(phentsize)
283 sr.Seek(off, os.SEEK_SET) 284 sr.Seek(off, os.SEEK_SET)
284 p := new(Prog) 285 p := new(Prog)
285 switch f.Class { 286 switch f.Class {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 766 }
766 if t == tag { 767 if t == tag {
767 s, ok := getString(str, int(v)) 768 s, ok := getString(str, int(v))
768 if ok { 769 if ok {
769 all = append(all, s) 770 all = append(all, s)
770 } 771 }
771 } 772 }
772 } 773 }
773 return all, nil 774 return all, nil
774 } 775 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b