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

Unified Diff: src/pkg/debug/elf/file.go

Issue 6936058: code review 6936058: debug/elf: handle missing shstrndx in core files (Closed)
Patch Set: diff -r 9a0e4777ea8b https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pkg/debug/elf/file_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/debug/elf/file.go
===================================================================
--- a/src/pkg/debug/elf/file.go
+++ b/src/pkg/debug/elf/file.go
@@ -272,7 +272,8 @@
shnum = int(hdr.Shnum)
shstrndx = int(hdr.Shstrndx)
}
- if shstrndx < 0 || shstrndx >= shnum {
+
+ 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 ||
return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
}
@@ -367,6 +368,10 @@
f.Sections[i] = s
}
+ if len(f.Sections) == 0 {
+ return f, nil
+ }
+
// Load section header string table.
shstrtab, err := f.Sections[shstrndx].Data()
if err != nil {
« no previous file with comments | « no previous file | src/pkg/debug/elf/file_test.go » ('j') | no next file with comments »

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