[BACK]Return to elf.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfconv

Diff for /src/usr.bin/ctfconv/elf.c between version 1.5 and 1.6

version 1.5, 2017/09/29 16:05:53 version 1.6, 2017/09/30 10:15:59
Line 125 
Line 125 
                 if ((sh->sh_offset + sh->sh_size) > filesize)                  if ((sh->sh_offset + sh->sh_size) > filesize)
                         continue;                          continue;
   
                   if (sh->sh_entsize == 0)
                           continue;
   
                 if (strncmp(shstab + sh->sh_name, ELF_SYMTAB, snlen) == 0) {                  if (strncmp(shstab + sh->sh_name, ELF_SYMTAB, snlen) == 0) {
                         if (symtab != NULL)                          if (symtab != NULL)
                                 *symtab = (Elf_Sym *)(p + sh->sh_offset);                                  *symtab = (Elf_Sym *)(p + sh->sh_offset);
Line 154 
Line 157 
   
         /* Find the given section. */          /* Find the given section. */
         for (i = 0; i < eh->e_shnum; i++) {          for (i = 0; i < eh->e_shnum; i++) {
                   if ((eh->e_shoff + i * eh->e_shentsize) > filesize)
                           continue;
   
                 sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);                  sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);
   
                 if ((sh->sh_link >= eh->e_shnum) || (sh->sh_name >= shstabsz))                  if ((sh->sh_link >= eh->e_shnum) || (sh->sh_name >= shstabsz))
Line 242 
Line 248 
   
         /* Apply possible relocation. */          /* Apply possible relocation. */
         for (i = 0; i < eh->e_shnum; i++) {          for (i = 0; i < eh->e_shnum; i++) {
                   if ((eh->e_shoff + i * eh->e_shentsize) > filesize)
                           continue;
   
                 sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);                  sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize);
   
                 if (sh->sh_size == 0)                  if (sh->sh_size == 0)
Line 250 
Line 259 
                 if ((sh->sh_info != sidx) || (sh->sh_link != symtabidx))                  if ((sh->sh_info != sidx) || (sh->sh_link != symtabidx))
                         continue;                          continue;
   
                   if ((sh->sh_offset + sh->sh_size) > filesize)
                           continue;
   
                 switch (sh->sh_type) {                  switch (sh->sh_type) {
                 case SHT_RELA:                  case SHT_RELA:
                         rela = (Elf_RelA *)(p + sh->sh_offset);                          rela = (Elf_RelA *)(p + sh->sh_offset);
Line 259 
Line 271 
                                 roff = rela[j].r_offset;                                  roff = rela[j].r_offset;
                                 if (rsym >= nsymb)                                  if (rsym >= nsymb)
                                         continue;                                          continue;
                                   if (roff >= filesize)
                                           continue;
                                 sym = &symtab[rsym];                                  sym = &symtab[rsym];
                                 value = sym->st_value + rela[j].r_addend;                                  value = sym->st_value + rela[j].r_addend;
   
Line 276 
Line 290 
                                 rtyp = ELF_R_TYPE(rel[j].r_info);                                  rtyp = ELF_R_TYPE(rel[j].r_info);
                                 roff = rel[j].r_offset;                                  roff = rel[j].r_offset;
                                 if (rsym >= nsymb)                                  if (rsym >= nsymb)
                                           continue;
                                   if (roff >= filesize)
                                         continue;                                          continue;
                                 sym = &symtab[rsym];                                  sym = &symtab[rsym];
                                 value = sym->st_value;                                  value = sym->st_value;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6