Skip to content

Commit

Permalink
kldxref: Appease a Coverity warning
Browse files Browse the repository at this point in the history
While parsing .dynamic, nsym is set when parsing the symbol table from
.dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
The value of nsym isn't validated until after a check for
ef->ef_symtab being NULL, so nsym always has a valid value when it is
read.  However, that chain of events is a bit much for static analysis
to follow, so initialize nsym to 0 before parsing sections to quiet
the warning.

Reported by:	Coverity Scan
CID:		1532339
Sponsored by:	DARPA
  • Loading branch information
bsdjhb committed Mar 12, 2024
2 parents 503e048 + d281fec commit eb5ab19
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions usr.sbin/kldxref/ef.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn)
goto out;
}

nsym = 0;
for (i = 0; i < nshdr; i++) {
switch (shdr[i].sh_type) {
case SHT_HASH:
Expand Down

0 comments on commit eb5ab19

Please sign in to comment.