From: Nathan Wagner Date: Sat, 26 Dec 2015 22:37:20 +0000 (+0000) Subject: added file type tests for soname X-Git-Tag: v0.1.6~207 X-Git-Url: https://pd.if.org/git/?a=commitdiff_plain;h=489ad6b12bcdfd554acd0908a1770187e76e436d;hp=8a8558dfc350661e2f9af3a0e3a41be7e2cd8154;p=zpackage added file type tests for soname --- diff --git a/elf/soname.c b/elf/soname.c index 9977015..aa683a5 100644 --- a/elf/soname.c +++ b/elf/soname.c @@ -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) {