1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

added range checks for section string

This commit is contained in:
David Inglis 2003-07-28 13:36:57 +00:00
parent 0a8f96e1d2
commit 8daef5ac9c

View file

@ -167,6 +167,8 @@ public class Elf {
public String toString() { public String toString() {
try { try {
if ( section_strtab == null ) { if ( section_strtab == null ) {
if ( ehdr.e_shstrndx > sections.length || ehdr.e_shstrndx < 0)
return EMPTY_STRING;
int size = (int)sections[ehdr.e_shstrndx].sh_size; int size = (int)sections[ehdr.e_shstrndx].sh_size;
if ( size <= 0 || size > efile.length() ) if ( size <= 0 || size > efile.length() )
return EMPTY_STRING; return EMPTY_STRING;
@ -555,18 +557,18 @@ public class Elf {
} }
private void commonSetup( String file, long offset, boolean filton ) private void commonSetup( String file, long offset, boolean filton )
throws IOException throws IOException
{ {
this.cppFiltEnabled = filton; this.cppFiltEnabled = filton;
efile = new ERandomAccessFile(file, "r");
efile.setFileOffset( offset );
try { try {
efile = new ERandomAccessFile(file, "r");
efile.setFileOffset( offset );
ehdr = new ELFhdr(); ehdr = new ELFhdr();
this.file = file; this.file = file;
} finally { } finally {
if ( ehdr == null ) { if ( ehdr == null ) {
efile.close(); dispose();
} }
} }
} }