/* Symbol, variable and name lookup.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is part of libctf.
};
int h = s[len - 1] + (int) len - 105;
- const struct qual *qp = &qhash[h];
+ const struct qual *qp;
- return (h >= 0 && (size_t) h < sizeof (qhash) / sizeof (qhash[0])
- && (size_t) len == qp->q_len &&
+ if (h < 0 || (size_t) h >= sizeof (qhash) / sizeof (qhash[0]))
+ return 0;
+
+ qp = &qhash[h];
+
+ return ((size_t) len == qp->q_len &&
strncmp (qp->q_name, s, qp->q_len) == 0);
}
int in_child = 0;
ntype = CTF_ERR;
- if (child && idx <= child->ctf_pptrtab_len)
+ if (child && idx < child->ctf_pptrtab_len)
{
ntype = child->ctf_pptrtab[idx];
if (ntype)
idx = LCTF_TYPE_TO_INDEX (fp, ntype);
ntype = CTF_ERR;
- if (child && idx <= child->ctf_pptrtab_len)
+ if (child && idx < child->ctf_pptrtab_len)
{
ntype = child->ctf_pptrtab[idx];
if (ntype)
cache->ctf_symhash_latest) < 0)
goto oom;
if (strcmp (sym.st_name, symname) == 0)
- return cache->ctf_symhash_latest++;
- }
- break;
+ return cache->ctf_symhash_latest++;
+ }
+ break;
case sizeof (Elf32_Sym):
{
Elf32_Sym *symp = (Elf32_Sym *) sp->cts_data;
cache->ctf_symhash_latest) < 0)
goto oom;
if (strcmp (sym.st_name, symname) == 0)
- return cache->ctf_symhash_latest++;
- }
+ return cache->ctf_symhash_latest++;
+ }
break;
default:
ctf_set_errno (fp, ECTF_SYMTAB);
*name = ctf_strptr (fp, idx[i->ctn_n]);
sym = tab[i->ctn_n++];
- } while (sym == -1u || sym == 0);
+ }
+ while (sym == -1u || sym == 0);
}
else
{
if (symidx > fp->ctf_dynsymmax)
goto try_parent;
- sym = fp->ctf_dynsymidx[symidx];
+ sym = fp->ctf_dynsymidx[symidx];
err = ECTF_NOTYPEDAT;
if (!sym || (sym->st_shndx != STT_OBJECT && sym->st_shndx != STT_FUNC))
goto try_parent;