Skip to content

Commit

Permalink
ldelf: check presence of sym_tab in e32_relocate()
Browse files Browse the repository at this point in the history
Adds checks in e32_relocate() that sym_tab is assigned a symbol table
before using it.

This fixes coverity scan:
CID 1501826 (#1 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#2 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#3 of 3): Explicit null dereferenced (FORWARD_NULL)

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed May 27, 2021
1 parent 6d00f28 commit 6c9c359
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ldelf/ta_elf_rel.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,25 @@ static void e32_relocate(struct ta_elf *elf, unsigned int rel_sidx)
break;
case R_ARM_GLOB_DAT:
case R_ARM_JUMP_SLOT:
if (!sym_tab)
err(TEE_ERROR_BAD_FORMAT,
"Missing symbol table");
e32_process_dyn_rel(sym_tab, num_syms, str_tab,
str_tab_size, rel, where);
break;
case R_ARM_TLS_DTPMOD32:
if (!sym_tab)
err(TEE_ERROR_BAD_FORMAT,
"Missing symbol table");
mod = elf;
e32_tls_get_module(sym_tab, num_syms, str_tab,
str_tab_size, rel, &mod);
*where = mod->tls_mod_id;
break;
case R_ARM_TLS_DTPOFF32:
if (!sym_tab)
err(TEE_ERROR_BAD_FORMAT,
"Missing symbol table");
e32_tls_resolve(sym_tab, num_syms, str_tab,
str_tab_size, rel, &val);
*where = val;
Expand Down

0 comments on commit 6c9c359

Please sign in to comment.