• Dmitry Safonov's avatar
    compel/tests: add sections table & string section tests · 3c966037
    Dmitry Safonov authored
    Now it has 4 new tests:
    ok 4 - section table start oob (64-bit ELF)
    ok 5 - too many sections in table (64-bit ELF)
    ok 6 - strings section's header oob of section table (64-bit ELF)
    ok 7 - strings section oob (64-bit ELF)
    
    I.e, if we forget to test string section's header oob with the next diff:
    >--- a/compel/handle-elf.c
    >+++ b/compel/handle-elf.c
    >@@ -122,7 +122,7 @@ static const char *get_strings_section(Ehdr_t *hdr, uintptr_t mem,
    >                pr_err("String section @%#zx size %#lx is out of [%#zx, %#zx)\n",
    >                        addr, (unsigned long)secstrings_hdr->sh_size,
    >                        mem, mem + size);
    >-               return NULL;
    >+               return (void*)addr;
    >        }
    >
    >        return (void*)addr;
    
    It will yell with:
    ok 1 - zero ELF header (64-bit ELF)
    ...
    not ok 6 - strings section's header oob of section table (64-bit ELF), expected -4 but ret is -1
    ...
    not ok 12 - strings section's header oob of section table (32-bit ELF), expected -4 but ret is -1
    
    Should be more useful when I add relocations tests after all.
    (but this seems for me useful too).
    
    Cc: Cyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
    Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
    3c966037
Name
Last commit
Last update
Documentation Loading commit data...
compel Loading commit data...
contrib Loading commit data...
coredump Loading commit data...
crit Loading commit data...
criu Loading commit data...
images Loading commit data...
include/common Loading commit data...
lib Loading commit data...
scripts Loading commit data...
soccr Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
INSTALL.md Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.install Loading commit data...
Makefile.versions Loading commit data...
README.md Loading commit data...