]> pd.if.org Git - zpackage/commitdiff
added file type tests for soname
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 26 Dec 2015 22:37:20 +0000 (22:37 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 26 Dec 2015 22:37:20 +0000 (22:37 +0000)
elf/soname.c

index 99770159b4e3109a0cd0175c7faf87994fb99198..aa683a53acb3bf726218dc37af3c44e51a396c1a 100644 (file)
@@ -22,6 +22,13 @@ int main(int ac, char **av) {
        char *name, *dynname;
        Elf64_Dyn *dent;
 
+       if (lstat(av[1], &sbuf) == -1) {
+               exit(1);
+       }
+       if (!S_ISREG(sbuf.st_mode)) {
+               exit(1);
+       }
+
        elffd = open(av[1], O_RDONLY);
        if (elffd == -1) {
                exit(1);
@@ -29,6 +36,9 @@ int main(int ac, char **av) {
        if (fstat(elffd, &sbuf) == -1) {
                exit(1);
        }
+       if (!S_ISREG(sbuf.st_mode)) {
+               exit(1);
+       }
 
        elfbase = mmap(0, sbuf.st_size, PROT_READ,MAP_PRIVATE, elffd, 0);
        if (!elfbase) {