diff options
| author | Mark Wielaard <[email protected]> | 2014-11-17 23:15:45 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-11-17 23:19:03 +0100 |
| commit | 5c1a45c2d370e7fd1149fa74a9382e202fbfe8fe (patch) | |
| tree | b41fc506962bb78a5b9176600abd968146bc7e2b /src/elfcmp.c | |
| parent | 7df0da33f4789e264242a4cb8af30c0aefe6d6b4 (diff) | |
Check elf_strptr didn't fail getting section name.
Since elf_strptr can fail and return NULL we should always check the result
before usage. Debug sections are only handled by section name, so make sure
the name actually exists.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/elfcmp.c')
| -rw-r--r-- | src/elfcmp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/elfcmp.c b/src/elfcmp.c index 2d85f0b2..c420019f 100644 --- a/src/elfcmp.c +++ b/src/elfcmp.c @@ -1,5 +1,5 @@ /* Compare relevant content of two ELF files. - Copyright (C) 2005-2012 Red Hat, Inc. + Copyright (C) 2005-2012, 2014 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. @@ -355,7 +355,8 @@ main (int argc, char *argv[]) sym1->st_name); const char *name2 = elf_strptr (elf2, shdr2->sh_link, sym2->st_name); - if (unlikely (strcmp (name1, name2) != 0 + if (unlikely (name1 == NULL || name2 == NULL + || strcmp (name1, name2) != 0 || sym1->st_value != sym2->st_value || (sym1->st_size != sym2->st_size && sym1->st_shndx != SHN_UNDEF) |
