Print this page
3450 elfdump crashes on non-Solaris/Linux objects

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/elfdump/common/elfdump.c
          +++ new/usr/src/cmd/sgs/elfdump/common/elfdump.c
↓ open down ↓ 2217 lines elided ↑ open up ↑
2218 2218   */
2219 2219  static void
2220 2220  versions(Cache *cache, Word shnum, const char *file, uint_t flags,
2221 2221      VERSYM_STATE *versym)
2222 2222  {
2223 2223          GElf_Word       cnt;
2224 2224          Cache           *verdef_cache = NULL, *verneed_cache = NULL;
2225 2225  
2226 2226  
2227 2227          /* Gather information about the version sections */
2228      -        bzero(versym, sizeof (*versym));
2229 2228          versym->max_verndx = 1;
2230 2229          for (cnt = 1; cnt < shnum; cnt++) {
2231 2230                  Cache           *_cache = &cache[cnt];
2232 2231                  Shdr            *shdr = _cache->c_shdr;
2233 2232                  Dyn             *dyn;
2234 2233                  ulong_t         numdyn;
2235 2234  
2236 2235                  switch (shdr->sh_type) {
2237 2236                  case SHT_DYNAMIC:
2238 2237                          /*
↓ open down ↓ 2493 lines elided ↑ open up ↑
4732 4731  int
4733 4732  regular(const char *file, int fd, Elf *elf, uint_t flags,
4734 4733      const char *wname, int wfd, uchar_t osabi)
4735 4734  {
4736 4735          enum { CACHE_NEEDED, CACHE_OK, CACHE_FAIL} cache_state = CACHE_NEEDED;
4737 4736          Elf_Scn         *scn;
4738 4737          Ehdr            *ehdr;
4739 4738          size_t          ndx, shstrndx, shnum, phnum;
4740 4739          Shdr            *shdr;
4741 4740          Cache           *cache;
4742      -        VERSYM_STATE    versym;
     4741 +        VERSYM_STATE    versym = { 0 };
4743 4742          int             ret = 0;
4744 4743          int             addr_align;
4745 4744  
4746 4745          if ((ehdr = elf_getehdr(elf)) == NULL) {
4747 4746                  failure(file, MSG_ORIG(MSG_ELF_GETEHDR));
4748 4747                  return (ret);
4749 4748          }
4750 4749  
4751 4750          if (elf_getshdrnum(elf, &shnum) == -1) {
4752 4751                  failure(file, MSG_ORIG(MSG_ELF_GETSHDRNUM));
↓ open down ↓ 406 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX