]> pd.if.org Git - zpackage/blobdiff - elf/soname.c
change elf.h to use local header
[zpackage] / elf / soname.c
index aa683a53acb3bf726218dc37af3c44e51a396c1a..8b6c451275f8a8e42d8f50cb58b028d380a7cc07 100644 (file)
@@ -9,7 +9,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <elf.h>
+
+#include "elf.h"
 
 int main(int ac, char **av) {
        void *elfbase;
@@ -36,9 +37,14 @@ int main(int ac, char **av) {
        if (fstat(elffd, &sbuf) == -1) {
                exit(1);
        }
+       /* not a regular file? */
        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) {