• 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
..
compel Loading commit data...
inhfd Loading commit data...
jenkins Loading commit data...
others Loading commit data...
zdtm Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
abrt.sh Loading commit data...
check_actions.py Loading commit data...
crit-recode.py Loading commit data...
criu.py Loading commit data...
empty-netns-prep.sh Loading commit data...
groups.desc Loading commit data...
inhfd.desc Loading commit data...
rpc_pb2.py Loading commit data...
show_action.sh Loading commit data...
umount2.c Loading commit data...
zdtm.desc Loading commit data...
zdtm.py Loading commit data...
zdtm_ct.c Loading commit data...
zdtm_mount_cgroups Loading commit data...