]> pd.if.org Git - zpackage/commitdiff
add test for file length to soname
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 2 Jan 2016 07:32:09 +0000 (07:32 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 2 Jan 2016 07:32:09 +0000 (07:32 +0000)
elf/soname.c

index aa683a53acb3bf726218dc37af3c44e51a396c1a..72d465ade86ba66398fd209251b80e9ad7055151 100644 (file)
@@ -36,9 +36,14 @@ int main(int ac, char **av) {
        if (fstat(elffd, &sbuf) == -1) {
                exit(1);
        }
        if (fstat(elffd, &sbuf) == -1) {
                exit(1);
        }
+       /* not a regular file? */
        if (!S_ISREG(sbuf.st_mode)) {
                exit(1);
        }
        if (!S_ISREG(sbuf.st_mode)) {
                exit(1);
        }
+       /* not at least the size of the elf header? */
+       if (sbuf.st_size < sizeof(Elf64_Ehdr)) {
+               exit(1);
+       }
 
        elfbase = mmap(0, sbuf.st_size, PROT_READ,MAP_PRIVATE, elffd, 0);
        if (!elfbase) {
 
        elfbase = mmap(0, sbuf.st_size, PROT_READ,MAP_PRIVATE, elffd, 0);
        if (!elfbase) {