diff options
author | John Baldwin <jhb@FreeBSD.org> | 2023-12-22 15:49:40 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-12-22 15:49:40 +0000 |
commit | d281fece432f97b4424b852f23dfe1f974b9e30d (patch) | |
tree | 04ab762c9a0547c26b1989b948294cfe333b76f2 | |
parent | 0d557cdf6f0e94e909acea065f3de2a28437ae74 (diff) | |
download | src-d281fece432f97b4424b852f23dfe1f974b9e30d.tar.gz src-d281fece432f97b4424b852f23dfe1f974b9e30d.zip |
kldxref: Appease a Coverity warning
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
-rw-r--r-- | usr.sbin/kldxref/ef.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c index 46d3dc1f4578..fd0782ff1dd0 100644 --- a/usr.sbin/kldxref/ef.c +++ b/usr.sbin/kldxref/ef.c @@ -361,6 +361,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: |